discord.py-尝试制作仅适用于特定用户的命令

时间:2020-08-13 20:38:31

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

我正在尝试发出使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!')

1 个答案:

答案 0 :(得分:1)

没关系,感谢Python不和谐服务器的支持,我对其进行了修复:

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