less repetitions and detect command even with useless args
This commit is contained in:
parent
3faf06b62f
commit
1932635db1
1 changed files with 10 additions and 7 deletions
|
@ -9,6 +9,9 @@ class Commandes(commands.Cog):
|
|||
def __init__(self, client: commands.Bot):
|
||||
self.client = client
|
||||
self.keys = load(["PREFIX"])
|
||||
self.notModo = "tu n'es pas modérateur"
|
||||
self.notExistingCommand = "cette commande n'existe pas"
|
||||
self.alreadyExistingCommand = "cette commande existe déjà"
|
||||
|
||||
@commands.command()
|
||||
async def add(self, ctx: commands.Context, commandName = None, commandMessage = None):
|
||||
|
@ -20,9 +23,9 @@ class Commandes(commands.Cog):
|
|||
CommandesDB().ajoutCommande(commandName, commandMessage)
|
||||
await ctx.send(f"{ctx.author.name}, commande {commandName} ajoutée !")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, cette commande existe déjà.")
|
||||
await ctx.send(f"{ctx.author.name}, {self.alreadyExistingCommand}.")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, tu n'es pas modérateur.")
|
||||
await ctx.send(f"{ctx.author.name}, {self.notModo}.")
|
||||
|
||||
@commands.command()
|
||||
async def remove(self, ctx: commands.Context, commandName = None):
|
||||
|
@ -34,9 +37,9 @@ class Commandes(commands.Cog):
|
|||
CommandesDB().suppressionCommande(commandName)
|
||||
await ctx.send(f"{ctx.author.name}, commande {commandName} supprimée !")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, cette commande n'existe pas.")
|
||||
await ctx.send(f"{ctx.author.name}, {self.notExistingCommand}.")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, tu n'es pas modérateur.")
|
||||
await ctx.send(f"{ctx.author.name}, {self.notModo}.")
|
||||
|
||||
@commands.command()
|
||||
async def list(self, ctx: commands.Context):
|
||||
|
@ -59,13 +62,13 @@ class Commandes(commands.Cog):
|
|||
CommandesDB().ajoutCommande(commandName, commandMessage)
|
||||
await ctx.send(f"{ctx.author.name}, commande {commandName} modifiée !")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, cette commande n'existe pas.")
|
||||
await ctx.send(f"{ctx.author.name}, {self.notExistingCommand}.")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, tu n'es pas modérateur.")
|
||||
await ctx.send(f"{ctx.author.name}, {self.notModo}.")
|
||||
|
||||
@commands.Cog.event()
|
||||
async def event_message(self, message):
|
||||
if message.content.startswith(self.keys["PREFIX"]):
|
||||
command = CommandesDB().existeCommande(message.content[1:])
|
||||
command = CommandesDB().existeCommande(message.content[1:].split(" ")[0])
|
||||
if command[0]: # vérification si existe
|
||||
await message.channel.send(command[1]) # envois le contenu de la commande
|
||||
|
|
Loading…
Reference in a new issue