From 9b2c279b2e034bf68ea6a7c0d73c0681cfb4fbff Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sun, 20 May 2018 12:12:46 -0800 Subject: [PATCH 1/2] Added embed color --- run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/run.py b/run.py index 8fb24f6..04da018 100644 --- a/run.py +++ b/run.py @@ -17,6 +17,7 @@ class SebiMachine(commands.Bot, LoadConfig): # Initialize and attach config / settings LoadConfig.__init__(self) commands.Bot.__init__(self, command_prefix=self.defaultprefix) + self.embed_color = discord.Color(0x00FFFF) # Load plugins # Add your cog file name in this list From 9ab34e3362123999efda18260916ed0a9c183ceb Mon Sep 17 00:00:00 2001 From: annihilator708 Date: Sun, 20 May 2018 22:15:59 +0200 Subject: [PATCH 2/2] Add error handler --- run.py | 28 ++++++++++++++++++++++++++++ src/cogs/upload.py | 9 +++++++++ 2 files changed, 37 insertions(+) diff --git a/run.py b/run.py index 8fb24f6..662a8da 100644 --- a/run.py +++ b/run.py @@ -5,6 +5,8 @@ import discord from discord.ext import commands import json +import traceback +import random # Import custom files from src.config.config import LoadConfig @@ -31,6 +33,32 @@ class SebiMachine(commands.Bot, LoadConfig): if self.maintenance: print('MAINTENANCE ACTIVE') + async def on_command_error(self, ctx, error): + """ + The event triggered when an error is raised while invoking a command. + ctx : Context + error : Exception + """ + jokes = ["I\'m a bit tipsy, I took to many screenshots...", + "I am rushing to the 24/7 store to get myself anti-bug spray...", + "Organizing turtle race...", + "There is no better place then 127.0.0.1...", + "Recycling Hex Decimal...", + "No worry, I get fixed :^)...", + "R.I.P, press F for respect...", + "The bug repellent dit not work...", + "You found a bug in the program. Unfortunately the joke did not fit here, better luck next time..."] + + # catch error + error = error.__cause__ or error + tb = traceback.format_exception(type(error), error, error.__traceback__, limit=1, chain=False) + tb = ''.join(tb) + joke = random.choice(jokes) + fmt = f'**`{self.defaultprefix}{ctx.command}`**\n{joke}\n\n**{type(error).__name__}:**:\n```py\n{tb}\n```' + simple_fmt = f'**`{self.defaultprefix}{ctx.command}`**\n{joke}\n\n**{type(error).__name__}:**:\n**`{error}`**' + await ctx.send(fmt) + + if __name__ == '__main__': client = SebiMachine() # Make sure the key stays private. diff --git a/src/cogs/upload.py b/src/cogs/upload.py index 7e77075..9ccd8f7 100644 --- a/src/cogs/upload.py +++ b/src/cogs/upload.py @@ -78,5 +78,14 @@ class Upload: else: await ctx.send(f'Loaded `{extension}`.') + @commands.command() + async def gitserver(self, ctx): + """Pull latest commits, TMP until we have a solution""" + if ctx.author.id not in self.bot.ownerlist: + return await ctx.send('Only my creator can use me like this :blush:', delete_after=1) + import os + pull = os.popen('git pull').read() + await ctx.send(f'Pull complete\n```sh\n{pull}\n```') + def setup(bot): bot.add_cog(Upload(bot)) \ No newline at end of file