Discord owner not showing in command in discord.py.l

Question:

If you have not understood my question so let me explain .I am making a discord bot in which i am making a serverinfo command . In command all things working fine except onw thing .In owner section it is showing none although i have given all the permissions.Below are my code and results.
code:-

@client.command()
    async def server(ctx):
        name = str(ctx.guild.name)
        description = str(ctx.guild.description)
    
        owner = str(ctx.guild.owner)
        id = str(ctx.guild.id)
        region = str(ctx.guild.region)
        memberCount = str(ctx.guild.member_count)
    
        icon = str(ctx.guild.icon_url)
    
        embed = discord.Embed(
            title=name + " Server Information",
            description=description,
            color=discord.Color.blue()
        )[enter image description here][1]
        embed.set_thumbnail(url=icon)
        embed.add_field(name="Owner", value=owner, inline=True)
        embed.add_field(name="Server ID", value=id, inline=True)
        embed.add_field(name="Region", value=region, inline=True)
        embed.add_field(name="Member Count", value=memberCount, inline=True)
    
        await ctx.send(embed=embed)

This is the result

Asked By: Yash

||

Answers:

I‘m not 100% sure, sorry if I‘m wrong. But I‘ve tried it for my own discord bot and it worked. I think you have to enable intents on discord.dev and the add the following code (that‘s at least how I did it):

# at the start:
intents = discord.Intents().all()
# and then add this to the existing bot:
bot = commands.Bot(command_prefix="(Enter prefix here)",intents=intents)

I hope this works 🙂

Answered By: bad_coder

I have had this same problem aswell, i believe it could be that the owner wasn’t online at the time the bot joined.

Answered By: superhackedmonkey
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.