discord.py is only sending "objects" rather than actual information

Viewed 109

Here is the problem:
https://i.stack.imgur.com/2YQPn.png

Here's my code:

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)

Just so it's clear, what I want is it to send actual info not these objects.

1 Answers

"Guild" is not an object, but rather a class.

class discord.Guild

Using str() on fields of Guild therefore doesn't return any values but rather information on the attributes of the class. I suggest that you properly instantiate an object of the Class Guild using

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

You can find more information on this routine in the docs and access information like this:

my_guild.name
Related