From 2ccc10174df026f3a8dd2e7249868f28ca5db96b Mon Sep 17 00:00:00 2001 From: roblabla Date: Sun, 3 Mar 2019 15:12:30 +0100 Subject: [PATCH] Fix style in invites.py and logs.py --- cogs/invites.py | 18 ++++++++++++++---- cogs/logs.py | 10 ++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cogs/invites.py b/cogs/invites.py index 44674b5..5a11404 100644 --- a/cogs/invites.py +++ b/cogs/invites.py @@ -14,11 +14,20 @@ class Invites(Cog): async def invite(self, ctx): welcome_channel = self.bot.get_channel(config.welcome_channel) author = ctx.message.author - reason = f"Created by {author.name}#{author.discriminator} ({author.id})" - invite = await welcome_channel.create_invite(max_age = 0, max_uses = 1, temporary = True, unique = True, reason = reason) + reason = f"Created by {str(author)} ({author.id})" + invite = await welcome_channel.create_invite(max_age = 0, + max_uses = 1, temporary = True, unique = True, reason = reason) + with open("data/invites.json", "r") as f: invites = json.load(f) - invites[invite.id] = { "uses": 0, "url": invite.url, "max_uses": 1, "code": invite.code } + + invites[invite.id] = { + "uses": 0, + "url": invite.url, + "max_uses": 1, + "code": invite.code + } + with open("data/invites.json", "w") as f: f.write(json.dumps(invites)) @@ -26,7 +35,8 @@ class Invites(Cog): try: await ctx.author.send(f"Created single-use invite {invite.url}") except discord.errors.Forbidden: - await ctx.send(ctx.author.mention + " I could not send you the invite. Send me a DM so I can reply to you.") + await ctx.send(f"{ctx.author.mention} I could not send you the \ + invite. Send me a DM so I can reply to you.") def setup(bot): diff --git a/cogs/logs.py b/cogs/logs.py index e87edfd..4e99694 100644 --- a/cogs/logs.py +++ b/cogs/logs.py @@ -37,7 +37,12 @@ class Logs(Cog): # Add unknown active invites. Can happen if invite was manually created for invite in real_invites: if invite.id not in invites: - invites[invite.id] = { "uses": 0, "url": invite.url, "max_uses": invite.max_uses, "code": invite.code } + invites[invite.id] = { + "uses": 0, + "url": invite.url, + "max_uses": invite.max_uses, + "code": invite.code + } probable_invites_used = [] items_to_delete = [] @@ -68,7 +73,8 @@ class Logs(Cog): elif len(probable_invites_used) == 0: invite_used = "Unknown" else: - invite_used = "One of: " + ", ".join([x["code"] for x in probable_invites_used]) + invite_used = "One of: " + invite_used += ", ".join([x["code"] for x in probable_invites_used]) # Check if user account is older than 15 minutes age = member.joined_at - member.created_at