使用以下代码行:
@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
关于python-3.x - 消息对象没有属性 'server',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50651305/