消息对象没有属性“服务器" [英] Message object has no attribute 'server'
本文介绍了消息对象没有属性“服务器"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用以下代码行:
@bot.command()
async def report(ctx):
author = ctx.message.author
server = ctx.message.server
wait ctx.send("Author: " + str(author) + "
Server: " + str(server))
我得到错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'server'
导入库没有问题,因为我可以将行更改为 ctx.message.channel
并获取频道名称.author
也收集得很好.但是 server
没有.我也根据一些建议尝试使用 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屋!
查看全文