🔴 Converted all of connectFour to slash commands

This commit is contained in:
NikolajDanger
2021-04-03 23:16:17 +02:00
parent 1a2ead8448
commit b34a126ed1
6 changed files with 229 additions and 169 deletions

View File

@ -1,4 +1,4 @@
import discord, traceback, discord_slash
import discord, traceback, discord_slash, sys
from discord.ext import commands
class EventHandler():
@ -31,8 +31,6 @@ class ErrorHandler():
elif isinstance(error, commands.errors.MissingRequiredArgument):
self.bot.log(f"{error}",str(ctx.channel_id))
await ctx.send("Missing command parameters (error code 002). Try using `!help [command]` to find out how to use the command.")
elif isinstance(error, discord_slash.error.AlreadyResponded):
self.bot.log("Defer failed")
else:
exception = traceback.format_exception(type(error), error, error.__traceback__)
stopAt = "\nThe above exception was the direct cause of the following exception:\n\n"
@ -48,11 +46,15 @@ class ErrorHandler():
await ctx.send("Something went wrong (error code 000)")
async def on_error(self, method):
exception = traceback.format_exc()
stopAt = "\nThe above exception was the direct cause of the following exception:\n\n"
if stopAt in exception:
index = exception.index(stopAt)
exception = exception[:index]
errorType = sys.exc_info()[0]
if errorType == discord.errors.NotFound:
self.bot.log("Deleted message before I could add all reactions")
else:
exception = traceback.format_exc()
stopAt = "\nThe above exception was the direct cause of the following exception:\n\n"
if stopAt in exception:
index = exception.index(stopAt)
exception = exception[:index]
exceptionString = "".join(exception)
self.bot.log([f"exception in {method}", f"{exceptionString}"], level = 40)
exceptionString = "".join(exception)
self.bot.log([f"exception in {method}", f"{exceptionString}"], level = 40)

View File

@ -55,10 +55,10 @@ class databaseFuncs():
if user != None:
return user["user name"]
elif userID == "Gwendolyn":
return userID
elif userID == f"#{self.bot.user.id}":
return "Gwendolyn"
else:
self.bot.log("Couldn't find user "+userID)
self.bot.log(f"Couldn't find user {userID}")
return userID
def getID(self,userName):
@ -70,7 +70,7 @@ class databaseFuncs():
self.bot.log("Couldn't find user "+userName)
return None
def deleteGame(self, gameType,channel):
def deleteGame(self, gameType, channel):
self.bot.database[gameType].delete_one({"_id":channel})
def stopServer(self):