Fix merge

This commit is contained in:
annihilator708 2018-05-20 22:19:28 +02:00
commit aee2876f7e
4 changed files with 37 additions and 7 deletions

2
.gitignore vendored
View File

@ -105,3 +105,5 @@ venv.bak/
/src/config/Config.json /src/config/Config.json
/src/config/PrivateConfig.json /src/config/PrivateConfig.json
.idea/
/external_packages/

View File

@ -3,3 +3,5 @@ Guild-bot
In the folder "external_packages" you can find the discord.py rewrite module. In the folder "external_packages" you can find the discord.py rewrite module.
Make sure this one is installed. Make sure this one is installed.
When you add your cog makesure to add it also in the bot initial fase. Which can be found in run.py.

29
run.py
View File

@ -5,6 +5,8 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
import json import json
import traceback
import random
# Import custom files # Import custom files
from src.config.config import LoadConfig from src.config.config import LoadConfig
@ -17,6 +19,7 @@ class SebiMachine(commands.Bot, LoadConfig):
# Initialize and attach config / settings # Initialize and attach config / settings
LoadConfig.__init__(self) LoadConfig.__init__(self)
commands.Bot.__init__(self, command_prefix=self.defaultprefix) commands.Bot.__init__(self, command_prefix=self.defaultprefix)
self.embed_color = discord.Color(0x00FFFF)
# Load plugins # Load plugins
# Add your cog file name in this list # Add your cog file name in this list
@ -31,6 +34,32 @@ class SebiMachine(commands.Bot, LoadConfig):
if self.maintenance: if self.maintenance:
print('MAINTENANCE ACTIVE') 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__': if __name__ == '__main__':
client = SebiMachine() client = SebiMachine()
# Make sure the key stays private. # Make sure the key stays private.

View File

@ -79,13 +79,10 @@ class Upload:
await ctx.send(f'Loaded `{extension}`.') await ctx.send(f'Loaded `{extension}`.')
@commands.command() @commands.command()
async def git(self, ctx): async def gitserver(self, ctx):
"""Pull latest commits""" """Pull latest commits, TMP until we have a solution"""
if ctx.author.id not in self.bot.ownerlist: 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) return await ctx.send('Only my creator can use me like this :blush:', delete_after=1)
pull = os.popen('git pull').read()
await ctx.send(f'Pull complete\n```sh\n{pull}\n```')
def setup(bot): def setup(bot):
bot.add_cog(Upload(bot)) bot.add_cog(Upload(bot))