“Izin Discord.py” Kode Jawaban

scord.py cara menggunakan izin

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

Periksa Periksa apakah pengguna memiliki pesan pengembalian izin jika tidak

@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

Atur Permisi Peran Discord.py

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

Izin Discord.py

@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

Jawaban yang mirip dengan “Izin Discord.py”

Pertanyaan yang mirip dengan “Izin Discord.py”

Lebih banyak jawaban terkait untuk “Izin Discord.py” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya