【发布时间】:2021-02-25 23:13:22
【问题描述】:
我有这个代码:
logging_channel=client.get_channel(776924690291097621)
embed = discord.Embed(
title = 'Command Used',
description = f"""
User's Id: {ctx.author.id}
User's Name: {ctx.author.name}
Command: !help
Guild Name: {discord.Message.guild}
Guild Id: {discord.Message.guild_id} """,
colour = discord.Colour.purple()
)
embed.set_footer(text = "Support Server")
embed.set_author(name = "")
await logging_channel.send(embed=embed)
它应该发送一个带有作者 ID、作者姓名、命令、公会名称和公会 ID 的嵌入。但是,当我运行它时,我得到了这个错误:
Command raised an exception: AttributeError: type object 'Message' has no attribute 'guild_id'
当我删除“discord.Message.guild_id”部分时,它只会发送:
Guild:
我该如何解决这个问题,错误是什么意思?
【问题讨论】:
-
如果您删除了 guild_id,它将返回与消息相关的信息。 Message 下存在哪些键?在查找 api discordpy.readthedocs.io/en/latest/api.html#message 时,您可以看到您想要 sauy:
discord.Message.guild.id。我认为公会对象可能会利用 str 函数让它显示名称?
标签: python discord discord.py discord.py-rewrite