add error message to all commands
This commit is contained in:
parent
2a073723d5
commit
3faf06b62f
1 changed files with 25 additions and 11 deletions
|
@ -16,8 +16,13 @@ class Commandes(commands.Cog):
|
|||
if commandName == None or commandMessage == None:
|
||||
return
|
||||
if ctx.author.is_mod:
|
||||
CommandesDB().ajoutCommande(commandName, commandMessage)
|
||||
await ctx.send(f"Commande {commandName} ajoutée !")
|
||||
if CommandesDB().existeCommande(commandName)[0] == False:
|
||||
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à.")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, tu n'es pas modérateur.")
|
||||
|
||||
@commands.command()
|
||||
async def remove(self, ctx: commands.Context, commandName = None):
|
||||
|
@ -25,8 +30,13 @@ class Commandes(commands.Cog):
|
|||
if commandName == None:
|
||||
return
|
||||
if ctx.author.is_mod:
|
||||
CommandesDB().suppressionCommande(commandName)
|
||||
await ctx.send(f"Commande {commandName} supprimée !")
|
||||
if CommandesDB().existeCommande(commandName)[0]:
|
||||
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.")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, tu n'es pas modérateur.")
|
||||
|
||||
@commands.command()
|
||||
async def list(self, ctx: commands.Context):
|
||||
|
@ -44,14 +54,18 @@ class Commandes(commands.Cog):
|
|||
if commandName == None or commandMessage == None:
|
||||
return
|
||||
if ctx.author.is_mod:
|
||||
CommandesDB().suppressionCommande(commandName)
|
||||
CommandesDB().ajoutCommande(commandName, commandMessage)
|
||||
await ctx.send(f"Commande {commandName} modifiée !")
|
||||
if CommandesDB().existeCommande(commandName)[0]:
|
||||
CommandesDB().suppressionCommande(commandName)
|
||||
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.")
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, tu n'es pas modérateur.")
|
||||
|
||||
@commands.Cog.event()
|
||||
async def event_message(self, message):
|
||||
if message.content.startswith(self.keys["PREFIX"]):
|
||||
commandes = CommandesDB().listeCommande()
|
||||
for commande in commandes:
|
||||
if commande[0] == message.content[1:]:
|
||||
await message.channel.send(commande[1])
|
||||
command = CommandesDB().existeCommande(message.content[1:])
|
||||
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