【问题标题】:discord.py - Trying to make command that only works for a specific userdiscord.py - 尝试制作仅适用于特定用户的命令
【发布时间】:2020-12-03 18:11:15
【问题描述】:

我正在尝试发出一个命令,让我的 Discord 机器人重复我所说的话。但是,我只希望它为我工作。当我将 (ctx, *, message) 作为参数时,出现类似于“未定义消息”的错误。但是当唯一的参数是 (message) 时,它可以打印消息作者。但是现在当我运行命令时,机器人在 Discord 聊天中说这个错误:<discord.ext.commands.context.Context object at 0x0000014E1DE3D940>

这是我的代码:

@client.command()
async def say(message):
    if str(message.author) == "ASOwnerYT#7799":
        await message.channel.send(str(message))
else:
    print(f'{message.author} tried to use the say command!')

【问题讨论】:

    标签: python python-3.x discord.py discord.py-rewrite


    【解决方案1】:

    没关系,感谢 Python discord 服务器的支持,我修复了它:

    @client.command()
    @commands.is_owner()
    async def say(ctx, *, message):
        await ctx.send(message)
    

    【讨论】:

      猜你喜欢
      • 2021-08-30
      • 1970-01-01
      • 2018-08-27
      • 1970-01-01
      • 1970-01-01
      • 2018-01-21
      • 1970-01-01
      • 2021-07-02
      • 1970-01-01
      相关资源
      最近更新 更多