为了账号安全,请及时绑定邮箱和手机立即绑定

Discord.py 用户专用命令

Discord.py 用户专用命令

天涯尽头无女友 2023-06-13 10:41:07
我想发出一个只有我和我的朋友可以使用的命令,但我能找到的只是有作用,但我找不到任何东西来回答我的问题,因为所有的东西都不起作用,所以有什么办法让它起作用如果你想知道下面的脚本@client.command(aliases=['rl'])@commands.has_role('3Peak-Bot-Dev-[RN/ou3PwQFA9uqbXSa6E+ClZJA3uTjK3n3Sl7g5hins=]')async def reload(ctx):    guild = ctx.guild    embed = discord.Embed(title = f'Reloading!', color = 0xff6300)    await ctx.send(embed=embed)    return await ctx.bot.logout()
查看完整描述

1 回答

?
www说

TA贡献1775条经验 获得超8个赞

您可以添加代码来检查该命令是否由您或您的朋友使用该 ID 执行,例如:


@client.command(aliases=['rl'])

async def reload(ctx):

    yourID = 1234567890

    friendID = 1234567890

    if ctx.message.author.id == yourID or ctx.message.author.id == friendID:

        # Do something

    else:

        await ctx.send('You are not allowed to execute this command!')


查看完整回答
反对 回复 2023-06-13
  • 1 回答
  • 0 关注
  • 108 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信