ajout des alias dans la commande list et affichage des commandes modérateurs que aux modérateurs
This commit is contained in:
parent
0d345c3d03
commit
8058ab1453
1 changed files with 14 additions and 5 deletions
|
@ -5,7 +5,7 @@ from utils.commands import CommandesDB
|
|||
def prepare(client: commands.Bot):
|
||||
client.add_cog(Commandes(client))
|
||||
|
||||
class Commandes(commands.Cog):
|
||||
class Commandes(commands.Cog): # Les méthodes qui ont no_global_checks de Vrai ne sont autorisés qu'aux modérateurs
|
||||
def __init__(self, client: commands.Bot):
|
||||
self.client = client
|
||||
self.keys = load(["PREFIX"])
|
||||
|
@ -13,7 +13,7 @@ class Commandes(commands.Cog):
|
|||
self.notExistingCommand = "cette commande n'existe pas ou est intégré au bot"
|
||||
self.alreadyExistingCommand = "cette commande existe déjà"
|
||||
|
||||
@commands.command(name="add")
|
||||
@commands.command(name="add", no_global_checks=True)
|
||||
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:
|
||||
|
@ -27,7 +27,7 @@ class Commandes(commands.Cog):
|
|||
else:
|
||||
await ctx.send(f"@{ctx.author.name}, {self.notModo}.")
|
||||
|
||||
@commands.command(name="remove", aliases=["delete"])
|
||||
@commands.command(name="remove", aliases=["delete"], no_global_checks=True)
|
||||
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:
|
||||
|
@ -49,7 +49,16 @@ class Commandes(commands.Cog):
|
|||
cogs = self.client.cogs.values()
|
||||
for cog in cogs:
|
||||
for command in cog.commands.values():
|
||||
commandes.append((command.name,))
|
||||
name = command.name
|
||||
if command.no_global_checks:
|
||||
if not ctx.author.is_mod:
|
||||
continue
|
||||
if command.aliases:
|
||||
name += " (alias: "
|
||||
for aliase in command.aliases:
|
||||
name += f"{self.keys['PREFIX']}{aliase}, "
|
||||
name = f"{name[:-2]})"
|
||||
commandes.append((name,))
|
||||
|
||||
if len(commandes) > 0:
|
||||
message = f"@{ctx.author.name}, liste des commandes -> "
|
||||
|
@ -59,7 +68,7 @@ class Commandes(commands.Cog):
|
|||
else:
|
||||
await ctx.send(f"@{ctx.author.name}, aucune commande enrengistrée dans la base de donnée.")
|
||||
|
||||
@commands.command(name="edit")
|
||||
@commands.command(name="edit", no_global_checks=True)
|
||||
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:
|
||||
|
|
Loading…
Reference in a new issue