“Discord.py Permissões” Respostas de código

discord.py como usar permissões

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

Discord Py Verifique se o usuário tem uma mensagem de retorno de permissão, se não

@bot.command()
@has_permissions(kick_members=True)  
async def kick(self, ctx, Member: discord.Member):
          await bot.kick(Member)

@kick.error
async def kick_error(error, ctx):
   if isinstance(error, MissingPermissions):
       await ctx.send("You don't have permission to do that!")
Friendly Frog

Definir papel de permissões discord.py

server = ctx.message.server
perms = discord.Permissions(send_messages=False, read_messages=True)
await client.create_role(server, name='NoSend', permissions=perms)

Discord.py Permissões

@bot.command()
@commands.has_permissions(manage_messages=True)
async def test(ctx):
    await ctx.send('You can manage messages.')
   
# https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions
Envious Eel

Respostas semelhantes a “Discord.py Permissões”

Perguntas semelhantes a “Discord.py Permissões”

Mais respostas relacionadas para “Discord.py Permissões” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código