ajout des commandes du bot dans la liste des commandes
This commit is contained in:
parent
82da30c791
commit
cfc69bff53
1 changed files with 24 additions and 18 deletions
|
@ -10,11 +10,11 @@ class Commandes(commands.Cog):
|
|||
self.client = client
|
||||
self.keys = load(["PREFIX"])
|
||||
self.notModo = "tu n'es pas modérateur"
|
||||
self.notExistingCommand = "cette commande n'existe pas"
|
||||
self.notExistingCommand = "cette commande n'existe pas ou est intégré au bot"
|
||||
self.alreadyExistingCommand = "cette commande existe déjà"
|
||||
|
||||
@commands.command()
|
||||
async def add(self, ctx: commands.Context, commandName = None, commandMessage = None):
|
||||
@commands.command(name="add")
|
||||
async def _add(self, ctx: commands.Context, commandName = None, commandMessage = None):
|
||||
"""Ajoute une commande de la base de donnée du bot : add nomDeLaCommande messageDeLaCommande"""
|
||||
if commandName == None or commandMessage == None:
|
||||
return
|
||||
|
@ -27,8 +27,8 @@ class Commandes(commands.Cog):
|
|||
else:
|
||||
await ctx.send(f"{ctx.author.name}, {self.notModo}.")
|
||||
|
||||
@commands.command()
|
||||
async def remove(self, ctx: commands.Context, commandName = None):
|
||||
@commands.command(name="remove")
|
||||
async def _remove(self, ctx: commands.Context, commandName = None):
|
||||
"""Supprime une commande de la base de donnée du bot : remove nomDeLaCommande"""
|
||||
if commandName == None:
|
||||
return
|
||||
|
@ -41,20 +41,26 @@ class Commandes(commands.Cog):
|
|||
else:
|
||||
await ctx.send(f"{ctx.author.name}, {self.notModo}.")
|
||||
|
||||
@commands.command()
|
||||
async def list(self, ctx: commands.Context):
|
||||
@commands.command(name="list")
|
||||
async def _list(self, ctx: commands.Context):
|
||||
"""Affiche la liste des commandes de la base de donnée du bot"""
|
||||
commandes = CommandesDB().listeCommande()
|
||||
if len(commandes) > 0:
|
||||
message = ""
|
||||
for commande in commandes:
|
||||
message += f"{self.keys['PREFIX']}{commande[0]} -> {commande[1]}\n"
|
||||
await ctx.send(message)
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, Aucune commande enrengistrée dans la base de donnée")
|
||||
|
||||
@commands.command()
|
||||
async def edit(self, ctx: commands.Context, commandName = None, commandMessage = None):
|
||||
cogs = self.client.cogs.values()
|
||||
for cog in cogs:
|
||||
for command in cog.commands.values():
|
||||
commandes.append((command.name,))
|
||||
|
||||
if len(commandes) > 0:
|
||||
message = f"{ctx.author.name}, liste des commandes -> "
|
||||
for commande in commandes:
|
||||
message += f"{self.keys['PREFIX']}{commande[0]}, "
|
||||
await ctx.send(message[:-2])
|
||||
else:
|
||||
await ctx.send(f"{ctx.author.name}, aucune commande enrengistrée dans la base de donnée.")
|
||||
|
||||
@commands.command(name="edit")
|
||||
async def _edit(self, ctx: commands.Context, commandName = None, commandMessage = None):
|
||||
"""Modifie une commande de la base de donnée du bot : add nomDeLaCommande nouveauMessageDeLaCommande"""
|
||||
if commandName == None or commandMessage == None:
|
||||
return
|
||||
|
@ -71,6 +77,6 @@ class Commandes(commands.Cog):
|
|||
@commands.Cog.event()
|
||||
async def event_message(self, message):
|
||||
if message.content.startswith(self.keys["PREFIX"]):
|
||||
command = CommandesDB().existeCommande(message.content[1:].split(" ")[0])
|
||||
command = CommandesDB().existeCommande(message.content[1:].split(" ")[0]) # récupère le nom de la commande
|
||||
if command[0]: # vérification si existe
|
||||
await message.channel.send(command[1]) # envois le contenu de la commande
|
||||
await message.channel.send(f"{message.author.name}, {command[1]}") # envois le contenu de la commande
|
||||
|
|
Loading…
Reference in a new issue