async def on_member_ban(self, _, member): if member.guild and member.guild.id in self.config['ignore_servers']: return filename = shared_funcs.make_member_filename(member, "bans") string = "{} {}".format(self.make_member_message(member), "Was banned from guild") shared_funcs.write(filename, string)
async def on_member_join(self, member): if member.guild and member.guild.id in self.config['ignore_servers']: return filename = shared_funcs.make_member_filename(member, "joins-leaves") string = "{} {}".format(self.make_member_message(member), "Joined guild") shared_funcs.write(filename, string)
async def on_member_unban(self, guild, member): if guild and guild.id in self.config['ignore_servers']: return filename = self.make_member_separate_guild_filename( member, "bans", guild) string = "{} {}".format(self.make_member_message(member), "Was unbanned from guild") shared_funcs.write(filename, string)
async def on_message(self, message): if message.guild and message.guild.id in self.config['ignore_servers']: return filename = shared_funcs.make_filename(message) string = shared_funcs.make_message(message) shared_funcs.write(filename, string) if message.attachments and self.config['save_files']: await shared_funcs.save_files(message, filename)
async def archive_channel(self, ctx, channel_id: int): ''' Archives an individual channel. Normally there is little reason to call this, it's usually called under the hood by the other commands. ''' channel = self.bot.get_channel(channel_id) print('Started archival of {}'.format(str(channel))) store_message = [] async for message in channel.history(limit=None, reverse=True): path = shared_funcs.make_filename(message) store_message.append( [path, shared_funcs.make_message(message), message.created_at]) if message.attachments and self.config['save_files']: await shared_funcs.save_files(message, path) store_message.sort(key=lambda x: x[2]) for message in store_message: shared_funcs.write(message[0], message[1])
async def on_member_update(self, before, after): if before.guild and before.guild.id in self.config['ignore_servers']: return needs_registering, changed_data = self.member_changed(before, after) if not needs_registering: return strings = [] prefix = self.make_member_message(after) if "old_username" in changed_data: strings.append("{} {} {} {}".format( prefix, changed_data["old_username"], "is now known under the username", changed_data["new_username"])) if "added_roles" in changed_data: strings.append("{} {} {}".format( prefix, "Got the following roles added:", shared_funcs.stringify_roles(changed_data["added_roles"]))) if "deleted_roles" in changed_data: strings.append("{} {} {}".format( prefix, "Got the following roles removed:", shared_funcs.stringify_roles(changed_data["deleted_roles"]))) filename = shared_funcs.make_member_filename(after, "guild-updates") for string in strings: shared_funcs.write(filename, string)
async def on_message_edit(self, _, message): if message.guild and message.guild.id in self.config['ignore_servers']: return filename = shared_funcs.make_filename(message) string = shared_funcs.make_message(message) shared_funcs.write(filename, string)