亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

discord.py 只發送“對象”而不是實際信息

discord.py 只發送“對象”而不是實際信息

RISEBY 2022-12-06 16:30:25
這是問題所在:這是我的代碼:if message.content.startswith("%guildinfo"):        embed = discord.Embed(title="Guild Info: " + str(Guild.name), color=0xff00ae)        embed.add_field(name="Owned Emojis: ", value=Guild.emojis)        embed.add_field(name="Icon: ", value=Guild.icon)        embed.add_field(name="ID: ", value=Guild.id)        embed.add_field(name="Owner's ID: ", value=Guild.owner)        embed.add_field(name="Max Members: ", value=Guild.max_members)        embed.add_field(name="Banner: ", value=Guild.banner)        embed.add_field(name="Description: ", value=Guild.description)        embed.add_field(name="Splash: ", value=Guild.splash)        embed.add_field(name="How many boosters? ", value=Guild.premium_subscription_count)        embed.add_field(name="Channel List: ", value=Guild.channels)        embed.add_field(name="Voice Channels: ", value=Guild.voice_channels)        embed.add_field(name="Texr Channels: ", value=Guild.text_channels)        embed.add_field(name="Max # of Emojis: ", value=Guild.emoji_limit)        embed.add_field(name="Max Filesize: ", value=Guild.filesize_limit)        embed.add_field(name="Members: ", value=Guild.members)        embed.add_field(name="# of Members: ", value=Guild.member_count)        embed.add_field(name="Created at: ", value=Guild.created_at)        await message.channel.send(embed=embed)很明顯,我想要的是發送實際信息而不是這些對象。
查看完整描述

1 回答

?
蝴蝶刀刀

TA貢獻1801條經驗 獲得超8個贊

“公會”不是一個對象,而是一個類。

class discord.Guild

因此,在 Guild 的字段上使用 str() 不會返回任何值,而是返回有關類屬性的信息。我建議您使用正確實例化 Class Guild 的對象

my_guild = Bot.get_guild(id)   (pseudo-code)

您可以在文檔中找到有關此例程的更多信息,并訪問如下信息:

my_guild.name


查看完整回答
反對 回復 2022-12-06
  • 1 回答
  • 0 關注
  • 104 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號