使用以下代码行:
@bot.command()
async def report(ctx):
author = ctx.message.author
server = ctx.message.server
wait ctx.send("Author: " + str(author) + "\nServer: " + str(server))
我收到错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'server'
导入库不是问题,因为我可以将行更改为
ctx.message.channel
并获取 channel 名称。
author
收藏也不错。但是
server
才不是。我也试过使用
Guild
根据一些没有运气的建议。
请您参考如下方法:
discord.py 重写版本不使用 Server
消除公会和语音服务器之间的歧义,并与 Discord 的内部代码保持一致。
而不是做
discord.Server
message.server
etc.server
用
discord.Guild
message.guild
etc.guild