使用以下代码行:
@bot.command()
async def report(ctx):
author = ctx.message.author
server = ctx.message.server
wait ctx.send("Author: " + str(author) + "\nServer: " + str(server))
Run Code Online (Sandbox Code Playgroud)
我得到错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'server'
Run Code Online (Sandbox Code Playgroud)
导入库不是问题,因为我可以将行更改为ctx.message.channel并获取频道名称。在author太收集罚款。但server事实并非如此。我也尝试Guild过根据一些建议没有运气。