邮件对象没有属性“服务器” [英] Message object has no attribute 'server'

查看:75
本文介绍了邮件对象没有属性“服务器”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码行:

@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 并获取频道名称。 作者也可以收取罚款。但是服务器没有。我还尝试根据一些建议使用 Guild ,但没有运气。

It's not a problem with importing the libraries because I can change the line to ctx.message.channel and get the channel name. The author collects fine too. But the server does not. I have also tried using Guild as per some recommendations with no luck.

推荐答案

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

discord.py rewrite version does not use Server to remove ambiguity between guilds and voice servers and to remain consistent with Discord's internal code.

而不是

discord.Server
message.server
etc.server

使用

discord.Guild
message.guild
etc.guild

这篇关于邮件对象没有属性“服务器”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆