From 87a899f1bf017c947ae9227128e296ac5a7f5dfd Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Thu, 12 Mar 2020 09:07:46 -0700 Subject: [PATCH] [Tools] Add joined command --- tools/tools.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tools/tools.py b/tools/tools.py index 23781ca..9a67a3b 100644 --- a/tools/tools.py +++ b/tools/tools.py @@ -357,12 +357,31 @@ class Tools(commands.Cog): ) await awaiter.edit(embed=embed) + @commands.command() + async def joined(self, ctx, user: discord.Member = None): + """Show when a user joined the guild.""" + if not user: + user = ctx.author + if user.joined_at: + user_joined = user.joined_at.strftime("%d %b %Y %H:%M") + since_joined = (ctx.message.created_at - user.joined_at).days + joined_on = f"{user_joined} ({since_joined} days ago)" + else: + joined_on = "a mysterious date that not even Discord knows." + + if ctx.channel.permissions_for(ctx.guild.me).embed_links: + embed = discord.Embed( + description=f"{user.mention} joined this guild on {joined_on}.", + color=await ctx.embed_colour(), + ) + await ctx.send(embed=embed) + else: + await ctx.send(f"{user.display_name} joined this guild on {joined_on}.") + @commands.command(name="listguilds", aliases=["listservers", "guildlist", "serverlist"]) @checks.mod_or_permissions() async def listguilds(self, ctx): - """ - List the guilds|servers the bot is in - """ + """List the guilds|servers the bot is in.""" asciidoc = lambda m: "```asciidoc\n{}\n```".format(m) guilds = sorted(self.bot.guilds, key=lambda g: -g.member_count) header = ("```\n" "The bot is in the following {} server{}:\n" "```").format( @@ -587,7 +606,9 @@ class Tools(commands.Cog): form = "`{rpos:0{zpadding}}` - `{rid}` - `{rcolor}` - {rment} " max_zpadding = max([len(str(r.position)) for r in ctx.guild.roles]) rolelist = [ - form.format(rpos=r.position, zpadding=max_zpadding, rid=r.id, rment=r.mention, rcolor=r.color) + form.format( + rpos=r.position, zpadding=max_zpadding, rid=r.id, rment=r.mention, rcolor=r.color + ) for r in ctx.guild.roles ]