python-3.x - 消息对象没有属性 'server'

标签 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))

我收到错误:
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/

相关文章:

python - 列表切片并找到第二大值python

python - 与 sleep 命令相比,使用循环在 python 中等待更多 CPU 密集型?

python-3.x - 使用 lambda 中的 boto3 从 s3 读取和写入 excel 文件

python - Nextcord:无法访问服务器上的 ffmpeg

python - CommandOnCooldown 错误处理程序未捕获错误!已经测试了一切

python - Discord.py - SyntaxError f-string : empty expression not allowed

python - if 语句迭代标记化文本并删除不需要的项目

python - 如果文件已经存在,为什么我的机器人不替换文件?

python - 在discord.py中是否有类似于discord.js中的streamTime的东西?

audio - 从PyAudio播放Discord.py声音