async def on_member_update(self, before, after): if before.nick != after.nick: User.history_add(discord_id=after.id, server_id=after.guild.id, event="nick_change", user_name=after.display_name, timestamp=timestamp())
async def del_toon(self, ctx, *, msg): if MiscFunctions.role_name_has_access( admin_role_names, ctx.author.roles) or MiscFunctions.role_id_has_access( admin_role_ids, ctx.author.roles): if ctx.message.mentions: num = User.toon_delete_for_user(str( ctx.message.mentions[0].id)) if num > 0: await ctx.message.channel.send( "Deleted: " + str(num) + " characters for: <@!" + str(ctx.message.mentions[0].id) + ">") else: await ctx.message.channel.send( "Could not find/delete any characters for: <@!" + str(ctx.message.mentions[0].id) + ">") else: if User.toon_delete(msg.strip()) > 0: await ctx.message.channel.send("Character: \"" + msg.strip() + "\" Deleted.") else: await ctx.message.channel.send( "Character: \"" + msg.strip() + "\" could not be found/deleted.")
async def get_profile_image(self, ctx, *, msg): print("getting images") user_toon = msg.strip() if not ctx.message.mentions: if msg[0:3] == "<@!": user = msg[3:-1] else: result = User.toon_search(user_toon).first() user = result.discord_id else: user = str(ctx.message.mentions[0].id) if FileUtils.get_profile_image(user): limiter = 0 for x in FileUtils.get_profile_image(user): if limiter < 3: file = discord.File(FileUtils.path + "/" + user + "/" + x, filename=x) await ctx.send(file=file, content="Uploaded: " + x[:-4]) limiter += 1 else: await ctx.message.channel.send( "More than 3 images were found, limited to the first 3." ) break else: if not ctx.message.mentions: await ctx.message.channel.send( "Sorry, no profile images found associated with: " + user_toon) else: await ctx.message.channel.send( "No profile images found associated with: <@!" + str(ctx.message.mentions[0].id) + ">")
def list_summary(user_id, joined_at, guild_id): ret_message = [] query = User.history_joins(user_id, guild_id) temp_text = "<@!" + user_id + "> joined the server on " + joined_at.strftime("%b %d %y %H:%M:%S") + ".\n" \ "I have seen this user join the server " + str(query.count()) + " " \ "times.\n\n" # Get Previous nicknames previous_nicks = User.history_nicks(user_id) if previous_nicks: temp_text += "I have seen this user as these names: " + ", ".join( previous_nicks) + ".\n\n" if len(temp_text) > 0: ret_message.append(temp_text) # Get all of the users characters results = User.toon_search_by_user(user_id) for x in list_toons(results): ret_message.append(x) return ret_message
async def find_toon(self, ctx, *, msg): if not ctx.message.mentions: user_toon = msg.strip() results = User.toon_search(user_toon) if results.first() is not None: for x in results: await ctx.message.channel.send("Character: " + x.character + " was added to: <@!" + x.discord_id + "> on: " + x.timestamp) else: await ctx.message.channel.send("Could not find character: " + user_toon) else: user = str(ctx.message.mentions[0].id) results = User.toon_search_by_user(user) if results.first() is not None: for x in TextTools.list_toons(results): await ctx.message.channel.send(x) else: await ctx.message.channel.send( "Could not find any characters for: <@!" + str(ctx.message.mentions[0].id) + ">")
async def toon(self, ctx, *, msg): if not ctx.message.mentions: user_toon = msg.strip() user = ctx.message.author.id if "," in user_toon: toons = user_toon.split(",") for x in toons: User.toon_add(user, ctx.message.guild.id, x.strip(), timestamp()) await ctx.message.channel.send( ctx.message.author.display_name + ", I have added characters: " + user_toon + " to your profile.") else: User.toon_add(user, ctx.message.guild.id, user_toon, timestamp()) await ctx.message.channel.send( ctx.message.author.display_name + ", I have added character: " + user_toon + " to your profile.") else: user = str(ctx.message.mentions[0].id) user_toon = msg.split(' ', 1)[1].strip() if MiscFunctions.role_name_has_access(admin_role_names, ctx.author.roles) or \ MiscFunctions.role_id_has_access(admin_role_ids, ctx.author.roles): if "," in user_toon: toons = user_toon.split(",") for x in toons: User.toon_add(user, ctx.message.guild.id, x.strip(), timestamp()) await ctx.message.channel.send( "Added characters: " + user_toon + " to user: <@!" + str(ctx.message.mentions[0].id) + ">") else: User.toon_add(user, ctx.message.guild.id, user_toon, timestamp()) await ctx.message.channel.send( "Added character: " + user_toon + " to user: <@!" + str(ctx.message.mentions[0].id) + ">") else: await ctx.message.channel.send( ctx.message.author.name + " Sorry, but you do not have access to this " "function. Contact a bot admin.")
async def summary(self, ctx, *, msg): user = "" user_toon = msg.strip() if not ctx.message.mentions: results = User.toon_search(user_toon) if results.first() is not None: for x in results: converter = MemberConverter() user = await converter.convert(ctx, x.discord_id) break else: user = ctx.message.mentions[0] user_summary = TextTools.list_summary(str(user.id), user.joined_at, str(ctx.message.guild.id)) for x in user_summary: await ctx.message.channel.send(x) await Users.get_profile_image(self, ctx=ctx, msg=user.mention)
async def on_member_remove(self, member): User.history_add(discord_id=member.id, server_id=member.guild.id, event="leave", user_name=member.display_name, timestamp=timestamp())