消息对象没有属性 'server'
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) + "\nServer: " + str(server))
我收到错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'server'
导入库不是问题,因为我可以将行更改为 ctx.message.channel
并获取频道名称。 author
收集也很好。但是 server
没有。我也尝试过根据一些建议使用 Guild
,但没有成功。
discord.py 重写版本不使用 Server
来消除公会和语音服务器之间的歧义,并与 Discord 的内部代码保持一致。
而不是做
discord.Server
message.server
etc.server
使用
discord.Guild
message.guild
etc.guild
使用以下代码行:
@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
并获取频道名称。 author
收集也很好。但是 server
没有。我也尝试过根据一些建议使用 Guild
,但没有成功。
discord.py 重写版本不使用 Server
来消除公会和语音服务器之间的歧义,并与 Discord 的内部代码保持一致。
而不是做
discord.Server
message.server
etc.server
使用
discord.Guild
message.guild
etc.guild