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:
|
if commandName == None or commandMessage == None:
|
||||||
return
|
return
|
||||||
if ctx.author.is_mod:
|
if ctx.author.is_mod:
|
||||||
|
if CommandesDB().existeCommande(commandName)[0] == False:
|
||||||
CommandesDB().ajoutCommande(commandName, commandMessage)
|
CommandesDB().ajoutCommande(commandName, commandMessage)
|
||||||
await ctx.send(f"Commande {commandName} ajoutée !")
|
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()
|
@commands.command()
|
||||||
async def remove(self, ctx: commands.Context, commandName = None):
|
async def remove(self, ctx: commands.Context, commandName = None):
|
||||||
|
@ -25,8 +30,13 @@ class Commandes(commands.Cog):
|
||||||
if commandName == None:
|
if commandName == None:
|
||||||
return
|
return
|
||||||
if ctx.author.is_mod:
|
if ctx.author.is_mod:
|
||||||
|
if CommandesDB().existeCommande(commandName)[0]:
|
||||||
CommandesDB().suppressionCommande(commandName)
|
CommandesDB().suppressionCommande(commandName)
|
||||||
await ctx.send(f"Commande {commandName} supprimée !")
|
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()
|
@commands.command()
|
||||||
async def list(self, ctx: commands.Context):
|
async def list(self, ctx: commands.Context):
|
||||||
|
@ -44,14 +54,18 @@ class Commandes(commands.Cog):
|
||||||
if commandName == None or commandMessage == None:
|
if commandName == None or commandMessage == None:
|
||||||
return
|
return
|
||||||
if ctx.author.is_mod:
|
if ctx.author.is_mod:
|
||||||
|
if CommandesDB().existeCommande(commandName)[0]:
|
||||||
CommandesDB().suppressionCommande(commandName)
|
CommandesDB().suppressionCommande(commandName)
|
||||||
CommandesDB().ajoutCommande(commandName, commandMessage)
|
CommandesDB().ajoutCommande(commandName, commandMessage)
|
||||||
await ctx.send(f"Commande {commandName} modifiée !")
|
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()
|
@commands.Cog.event()
|
||||||
async def event_message(self, message):
|
async def event_message(self, message):
|
||||||
if message.content.startswith(self.keys["PREFIX"]):
|
if message.content.startswith(self.keys["PREFIX"]):
|
||||||
commandes = CommandesDB().listeCommande()
|
command = CommandesDB().existeCommande(message.content[1:])
|
||||||
for commande in commandes:
|
if command[0]: # vérification si existe
|
||||||
if commande[0] == message.content[1:]:
|
await message.channel.send(command[1]) # envois le contenu de la commande
|
||||||
await message.channel.send(commande[1])
|
|
||||||
|
|
Loading…
Reference in a new issue