async def invite_member(ctx, *args): channel = ctx.channel sender = ctx.message.author members, pars = parse_message_args(*args) if pars[0] > MAX_INVITES: pars[0] = MAX_INVITES if pars[1] > MAX_TIMOUT: pars[1] = MAX_TIMOUT if pars[1] < MIN_TIMOUT: pars[1] = MIN_TIMOUT print('members: ', members) print('pars: ', pars) if dealer_check(channel, sender, config_file): for mem_slug in members: target = get_member(channel, mem_slug) if not target.dm_channel: await target.create_dm() p_channel = target.dm_channel try: await inviter(p_channel, *pars, callback=ctx.channel) except discord.errors.Forbidden: await ctx.send(f'{target.mention} have blocked me!')
async def remove_dealer(ctx, *targets): sender = ctx.message.author if await client.is_owner(sender): print('dealer off command') channel = ctx.channel for slug in targets: member = get_member(channel, slug) if member: off_dealer(channel, member, config_file) await ctx.send( f'member {member.mention} removed from dealers list')
async def set_dealer(ctx, *targets): ''' gives "dealer" abilities for provided members ''' sender = ctx.message.author if await client.is_owner(sender): print('dealer add command') channel = ctx.channel for slug in targets: member = get_member(channel, slug) if member: save_dealer(channel, member, config_file) await ctx.send( f'member {member.mention} now has some abilities')
def __init__(self, conversation, data): self._conversation = conversation self.author = get_member(conversation, data['author']) self.content = data['message'] if len(self.content) > 768: self.cut_content = self.content[:768] + '... [Read more]' else: self.cut_content = self.content self.timestamp = datetime.strptime(data['timestamp'], r'%Y-%m-%dT%H:%M:%S.%fZ') self.attachment = Attachment(conversation, data['attachment']) if data['attachment'] else None self.starred = data['starred'] self.deleted = data['deleted'] self.ticks = TickEnum(data['ticks']) self.reply = get_message(conversation, data['reply']) if data['reply'] else None
async def send_survey(self, ctx, survey_id): """ Only member with admin role can run this command Command sends survey (id of survey in first parameter) to all users who are survey-fans (They answered in welcome quiz that they are ok with sending more surveys) """ logging.info(f"Executing send-survey command for survey_id {survey_id}") if db.check_survey_exists(survey_id): survey_fans = db.find_all_answer_alias_responders("survey-fan") users_who_started_survey = db.get_all_user_ids_from_survey_progress( survey_id ) final_users_to_send_survey_to = list( set(survey_fans) - set(users_who_started_survey) ) sent_to = [] for user_id in final_users_to_send_survey_to: member = get_member(self.bot, user_id) if member is None: # member does not longer exist continue channel_name = f"{member.display_name}-{db.get_survey_channel_name_suffix(survey_id)}" channel = await create_channel( get_server(self.bot), member, channel_name ) intro_message = db.get_survey_intro_message(survey_id) await send_welcome_message(channel, member, intro_message) db.create_user_survey_progress(survey_id, member.id, channel.id) await send_next_question(channel, member, survey_id) sent_to.append(member.display_name) await ctx.channel.send(f"Sent to {sent_to}") else: logging.info( f"Calling send-survey command for survey_id {survey_id}, but this survey doesn't exist" ) await ctx.channel.send(f"Survey with id {survey_id} wasn't found")
def get_pj(self, name): """ Args: name (Union[str, discord.Member]): can be a str or a discord.Member Returns: Optional[PJ]: a PJ object """ if isinstance(name, str): member = get_member(self.guild, name) if member: return self.get_pj_by_member(member) return self.get_pj_by_name(name) elif isinstance(name, discord.Member) or isinstance( name, discord.User): return self.get_pj_by_member(name) else: raise ALEDException( "Database.get_pj argument must be a str or a discord member object !" )
def get_distance_unit(self): return utils.get_member(DEF.declarations.distance_unit, self.decl_list)
def get_design(self): return utils.get_member(DEF.declarations.design, self.decl_list)
def get_busbitchars(self): return utils.get_member(DEF.declarations.busbitchars, self.decl_list)
def get_dividerchar(self): return utils.get_member(DEF.declarations.dividerchar, self.decl_list)
def get_namescasesensitive(self): return utils.get_member(DEF.declarations.namescasesensitive, self.decl_list)
def get_version(self): return utils.get_member(DEF.declarations.version, self.decl_list)