邮件对象没有属性“服务器”

web*_*eko 2 python-3.x discord.py discord.py-rewrite

使用以下代码行:

@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过根据一些建议没有运气。

Sam*_*ett 5

discord.py重写版本不能Server用来消除公会和语音服务器之间的歧义,并且不能与Discord的内部代码保持一致。

而不是做

discord.Server
message.server
etc.server
Run Code Online (Sandbox Code Playgroud)

使用

discord.Guild
message.guild
etc.guild
Run Code Online (Sandbox Code Playgroud)