Error embed are sent to ctx now, changed separator of 'decide' command, disabled 'update' command on windows systems

This commit is contained in:
Akumatic 2019-10-11 02:37:33 +02:00
parent c08aba1fbb
commit 8c55959633
3 changed files with 16 additions and 12 deletions

View File

@ -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()

View File

@ -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

View File

@ -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")