【问题标题】:Discord.py User Only CommandsDiscord.py 用户专用命令
【发布时间】:2020-12-11 23:35:15
【问题描述】:

我想做一个只有我和我的朋友可以使用的命令,但我能找到的只是有作用,但我找不到任何东西来回答我的问题,因为所有的东西都不起作用所以有什么办法可以得到它可以工作,如果您想知道下面的脚本

@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()

【问题讨论】:

  • discord.py 的 Discord 频道非常活跃。您可能想考虑在那里问同样的问题。

标签: python discord.py roles


【解决方案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.

【讨论】:

    猜你喜欢
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-08
    • 2021-06-28
    • 1970-01-01
    • 2021-03-26
    • 2019-02-06
    相关资源
    最近更新 更多