From 8c55959633ee1e25c66e189428ec8164587bac49 Mon Sep 17 00:00:00 2001 From: Akumatic Date: Fri, 11 Oct 2019 02:37:33 +0200 Subject: [PATCH] Error embed are sent to ctx now, changed separator of 'decide' command, disabled 'update' command on windows systems --- extensions/core.py | 11 ++++------- extensions/fun.py | 7 ++++--- extensions/updater.py | 10 ++++++++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/extensions/core.py b/extensions/core.py index 1338157..1a5245a 100644 --- a/extensions/core.py +++ b/extensions/core.py @@ -45,13 +45,10 @@ class Core(commands.Cog): if isinstance(error, commands.MissingPermissions): e.add_field(name="Missing Permissions", value="You don't have the permissions to use this command.") return await ctx.send(embed=e) - info = await self.bot.application_info() - user = info.owner - if user is not None: - e.add_field(name="Source", value=ctx.message.channel, inline=False) - e.add_field(name="Trigger", value=ctx.message.content, inline=False) - e.add_field(name="Error", value=f"{type(error).__name__} ({error})", inline=False) - await user.send(embed=e) + e.add_field(name="Source", value=ctx.message.channel, inline=False) + e.add_field(name="Trigger", value=ctx.message.content, inline=False) + e.add_field(name="Error", value=f"{type(error).__name__} ({error})", inline=False) + await ctx.send(embed=e) #Commands @commands.command() diff --git a/extensions/fun.py b/extensions/fun.py index f10b0ae..fa5feb0 100644 --- a/extensions/fun.py +++ b/extensions/fun.py @@ -131,7 +131,7 @@ class Fun(commands.Cog): @commands.command() async def decide(self, ctx, *, msg: str = None): - """Decides between given options. Every option should be separated by a ','""" + """Decides between given options. Every option should be separated by ' or '""" e = discord.Embed(description=ctx.author.mention) e.set_author(name=f"{ctx.author.display_name} ({ctx.author})", icon_url=ctx.author.avatar_url) if msg == None: @@ -139,12 +139,13 @@ class Fun(commands.Cog): e.color = discord.Color.red() e.add_field(name="No Options given", value="Please give at least one option") return await ctx.send(embed=e) - msg = msg.split(",") + msg = msg.split(" or ") e.color = discord.Color.blue() e.title = f"<< Decide between {len(msg)} options >>" for i in range(len(msg)): e.add_field(name=f"Option {i+1}", value=msg[i]) - e.add_field(name="Decision", value=random.choice(msg)) + decision = random.choice(msg) + e.add_field(name="Decision", value="''" if decision == "" else decision, inline=False) await ctx.send(embed=e) #Setup diff --git a/extensions/updater.py b/extensions/updater.py index 4f68fcd..cc70bdb 100644 --- a/extensions/updater.py +++ b/extensions/updater.py @@ -40,16 +40,22 @@ class Updater(commands.Cog): @commands.command() async def update(self, ctx): e = discord.Embed(title="<< Updating Modules >>") + if sys.platform == "win32": + e.color = discord.Color.red() + e.add_field(name="Currently not supported", value="Updating on Windows is currently disabled.") + return await ctx.send(embed=e) cog = None extensions = self.bot.extensions - botRootDir = os.path.sep.join(os.path.abspath(sys.argv[0]).split(os.path.sep)[:-1]) + botRootDir = os.path.dirname(os.path.abspath(sys.argv[0])) + l = [] for ext in extensions: + l.append(ext) + for ext in l: temp = ext.split(".") cog = self.bot.get_cog(temp[-1].capitalize()) if cog is not None and hasattr(cog, "update"): if cog.update["allowUpdate"]: path = f"{os.path.join(botRootDir, *temp)}.py" - #print(f"Comparing {path} with {cog.update['url']}") try: local = urllib.request.urlopen(f"file://{path}").read().decode("utf-8") remote = urllib.request.urlopen(self.getRequest(cog.update)).read().decode("utf-8")