Discord.py仅用户命令

时间:2020-08-23 00:06:32

标签: python discord.py roles

我想创建一个命令,只有我和我的朋友可以使用,但是我只能找到角色,但是我找不到任何可以回答我的问题的东西,因为一切都将不起作用,因此有任何方法可以获取它可以正常工作,如果您想知道下面的脚本

@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 个答案:

答案 0 :(得分:1)

您可以添加代码来检查命令是否由您或您的朋友使用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!')

如果您不知道如何获取用户ID,请here’s a good guide.