From 68dbd41ee10e3b1cbc89414064b6caf3ea4a3079 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Wed, 23 Mar 2022 01:21:38 +0000 Subject: [PATCH] Format code with black, yapf, autopep8 and isort This commit fixes the style issues introduced in 15f0cb4 according to the output from black, yapf, autopep8 and isort. Details: https://deepsource.io/gh/CoderN-P/Country-Bot/transform/4dcaf41a-425b-466d-9d62-9343ac47131d/ --- bot_utils/core.py | 86 ++++++++++----------- slash_commands/admin_commands/adminstuff.py | 59 +++++++------- 2 files changed, 65 insertions(+), 80 deletions(-) diff --git a/bot_utils/core.py b/bot_utils/core.py index c1fdacc..79cc71a 100644 --- a/bot_utils/core.py +++ b/bot_utils/core.py @@ -4,6 +4,7 @@ import topgg from pycord.ext import commands from thefuzz import fuzz + from bot_utils.background_tasks import BackgroundTasks from bot_utils.mongomethods import ( create_prefix, @@ -17,6 +18,7 @@ class CountryBot(commands.Bot): + def __init__(self): self.owner = 751594192739893298 self.description = "Check out our slash commands! Type `/` to bring up all of the slash commands! If you do not see any slash commands from country bot, then please kick country bot and use [this link to invite it again](https://discord.com/api/oauth2/authorize?client_id=810662403217948672&permissions=2048&scope=bot%20applications.commands)" @@ -30,19 +32,20 @@ def __init__(self): _ = SlashCommand(self, sync_commands=True) self.topgg_webhook = topgg.WebhookManager(self).dbl_webhook( - "/dblwebhook", "dbl_password" - ) + "/dblwebhook", "dbl_password") self.topgg_webhook.run(4355) - menu = DefaultMenu("◀️", "▶️", "❌") # You can copy-paste any icons you want. + menu = DefaultMenu("◀️", "▶️", + "❌") # You can copy-paste any icons you want. ending_note = "Type {help.clean_prefix}help command to get information on a command\nType {help.clean_prefix}help category to get information on a category\nPlease do not put text in <> or []\n<> = mandatory argument, [] = optional argument" - self.help_command = PrettyHelp( - navigation=menu, color=discord.Colour.red(), ending_note=ending_note - ) + self.help_command = PrettyHelp(navigation=menu, + color=discord.Colour.red(), + ending_note=ending_note) dbl_token = os.environ["TOPGGTOKEN"] - self.topggpy = topgg.DBLClient( - self, dbl_token, autopost=True, post_shard_count=True - ) + self.topggpy = topgg.DBLClient(self, + dbl_token, + autopost=True, + post_shard_count=True) self.tasks = BackgroundTasks(self) @@ -60,24 +63,18 @@ def run(self): self.run(os.getenv("TOKEN")) async def on_message(self, msg): - if ( - msg.content == f"<@810662403217948672> prefix" - or msg.content == f"<@!810662403217948672> prefix" - ): + if (msg.content == f"<@810662403217948672> prefix" + or msg.content == f"<@!810662403217948672> prefix"): prefix = self.bot.command_prefix(self.bot, msg) await msg.channel.send(f"My prefix in this server is `{prefix}`") - elif ( - msg.content == f"<@810662403217948672>prefix" - or msg.content == f"<@!810662403217948672>prefix" - ): + elif (msg.content == f"<@810662403217948672>prefix" + or msg.content == f"<@!810662403217948672>prefix"): prefix = self.bot.command_prefix(self.bot, msg) await msg.channel.send(f"My prefix in this server is `{prefix}`") - elif ( - msg.content == "<@810662403217948672>" - or msg.content == "<@!810662403217948672>" - ): + elif (msg.content == "<@810662403217948672>" + or msg.content == "<@!810662403217948672>"): prefix = self.bot.command_prefix(self.bot, msg) await msg.channel.send(f"My prefix in this server is `{prefix}`") @@ -106,17 +103,15 @@ async def on_dbl_vote(self, data): "Thanks for voting! Unfortunately since you have not made a country, you can't redeem any rewards :( To create a country type `.start` Remember, replace `.` with the prefix of the bot in the server you are in!" ) return - await update( - ( - user.id, - a[0][0], - a[0][1] + (1000 * (a[0][5] + 1)), - a[0][2], - a[0][3], - a[0][4], - a[0][10], - ) - ) + await update(( + user.id, + a[0][0], + a[0][1] + (1000 * (a[0][5] + 1)), + a[0][2], + a[0][3], + a[0][4], + a[0][10], + )) await update_coins((user.id, a[0][11] + (100 * a[0][5]))) await user.send( "Thanks for voting, I appreciate it! Check your profile to see the received rewards!" @@ -163,21 +158,18 @@ async def on_command_error(self, ctx, error): pass guild = self.bot.get_guild(821872779523522580) channel = discord.utils.get(guild.channels, name="bug-logs") - await channel.send( - embed=discord.Embed( - title="Error in executing a command", - description=f"New error when executing command: {ctx.command.name}\n**Error**: {error}", - ) - ) - - elif isinstance(error, discord.ext.commands.errors.MissingRequiredArgument): - await ctx.send( - embed=discord.Embed( - title="Incorrect Usage", - description=f"Correct Usage: ```{ctx.prefix}{ctx.command.name} {ctx.command.signature}```", - color=discord.Colour.red(), - ) - ) + await channel.send(embed=discord.Embed( + title="Error in executing a command", + description=f"New error when executing command: {ctx.command.name}\n**Error**: {error}", + )) + + elif isinstance(error, + discord.ext.commands.errors.MissingRequiredArgument): + await ctx.send(embed=discord.Embed( + title="Incorrect Usage", + description=f"Correct Usage: ```{ctx.prefix}{ctx.command.name} {ctx.command.signature}```", + color=discord.Colour.red(), + )) elif isinstance(error, discord.ext.commands.errors.MemberNotFound): embed = discord.Embed(title="Hmm", description=error.args[0]) diff --git a/slash_commands/admin_commands/adminstuff.py b/slash_commands/admin_commands/adminstuff.py index 69ba834..b869f84 100644 --- a/slash_commands/admin_commands/adminstuff.py +++ b/slash_commands/admin_commands/adminstuff.py @@ -8,65 +8,58 @@ class AdminCommands( - commands.Cog, - name="Admin/Configuration (slash)", - description="Commands only for admins", + commands.Cog, + name="Admin/Configuration (slash)", + description="Commands only for admins", ): + def __init__(self, bot): self.bot = bot - @cog_ext.cog_slash(description="Set up a channel to receive updates about the bot") + @cog_ext.cog_slash( + description="Set up a channel to receive updates about the bot") @commands.has_permissions(administrator=True) async def configurechannel(self, ctx, channel: discord.TextChannel): try: await create_update(channel.id) except: - await ctx.send( - embed=discord.Embed( - title="Hey!", - description="This channel has already been configured!", - ) - ) + await ctx.send(embed=discord.Embed( + title="Hey!", + description="This channel has already been configured!", + )) return try: - await channel.send( - embed=discord.Embed( - title="Success", - description="Channel is configured to receive updates about the bot!", - ) - ) + await channel.send(embed=discord.Embed( + title="Success", + description="Channel is configured to receive updates about the bot!", + )) await ctx.send(f"Great! {channel} is now configured!") except: - await ctx.send( - embed=discord.Embed( - title="Oh No!", - description=":x: I couldn't send mesages in that channel. Please provide a valid channel! Or make sure that I have permission to talk there!", - ) - ) + await ctx.send(embed=discord.Embed( + title="Oh No!", + description=":x: I couldn't send mesages in that channel. Please provide a valid channel! Or make sure that I have permission to talk there!", + )) await delete_update(channel.id) return - @cog_ext.cog_slash(description="Make a channel not receive updates about the bot") + @cog_ext.cog_slash( + description="Make a channel not receive updates about the bot") @commands.has_permissions(administrator=True) async def unconfigurechannel(self, ctx, channel: discord.TextChannel): try: await delete_update(int(channel.id)) except: - await ctx.send( - embed=discord.Embed( - title="Oh No!", description=":x: Please provide a valid channel!" - ) - ) + await ctx.send(embed=discord.Embed( + title="Oh No!", + description=":x: Please provide a valid channel!")) return - await ctx.send( - embed=discord.Embed( - title="Success", description=f"{channel} won't receive update messages" - ) - ) + await ctx.send(embed=discord.Embed( + title="Success", + description=f"{channel} won't receive update messages")) def setup(bot):