ASO*_*rYT 0 python python-3.x discord.py
我正在尝试发出一个命令,让我的 Discord 机器人重复我所说的话。然而,我只希望它对我有用。当我将 (ctx, *, 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!')
Run Code Online (Sandbox Code Playgroud)
没关系,感谢 Python Discord 服务器的支持,我修复了它:
@client.command()
@commands.is_owner()
async def say(ctx, *, message):
await ctx.send(message)
Run Code Online (Sandbox Code Playgroud)