“Comment limiter une commande à une autorisation dans Discord.py” Réponses codées

Comment limiter une commande à une autorisation dans Discord.py

# Make sure you don't have a command called "commands"
@client.command() # As usual
@commands.has_permissions(administrator=True) # Making sure the person executing the command has the permissions
async def foo(ctx):
	await ctx.send("Hello")
    #ect
HelloWorld

discord.py comment utiliser les autorisations

from discord import Member
from discord.ext.commands import has_permissions, MissingPermissions

@bot.command(name="kick", pass_context=True)
@has_permissions(manage_roles=True, ban_members=True)
async def _kick(ctx, member: Member):
    await bot.kick(member)

@_kick.error
async def kick_error(error, ctx):
    if isinstance(error, MissingPermissions):
        text = "Sorry {}, you do not have permissions to do that!".format(ctx.message.author)
        await bot.send_message(ctx.message.channel, text)
Courageous Crossbill

Réponses similaires à “Comment limiter une commande à une autorisation dans Discord.py”

Questions similaires à “Comment limiter une commande à une autorisation dans Discord.py”

Plus de réponses similaires à “Comment limiter une commande à une autorisation dans Discord.py” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code