Reputation: 11
@client.command()
async def server(ctx):
embed = discord.Embed(title = f"{ctx.guild.name} Info", description = "Information of this Server", color = discord.Colour.blue())
embed.add_field(name = '🆔Server ID', value = f"{ctx.guild.id}", inline = True)
embed.add_field(name = '📆Created On', value = ctx.guild.created_at.strftime("%b %d %Y"), inline = True)
embed.add_field(name = '👑Owner', value = f"{ctx.guild.owner}", inline = True)
embed.add_field(name = '👥Members', value = f'{ctx.guild.member_count} Members', inline = True)
embed.add_field(name = '💬Channels', value = f'{ctx.guild.text_channel_count} Text | {ctx.guild.voice_channel_count} Voice', inline = True)
embed.add_field(name = '🌎Region', value = f'{ctx.guild.region}', inline = True)
embed.set_thumbnail(url = ctx.guild.icon_url)
embed.set_footer(text = "⭐ • Duo")
embed.set_author(name = f'{ctx.guild.name}', url = embed.Empty, icon_url = {ctx.guild.icon_url})
await ctx.send(embed=embed)
I wrote this Code, everything seems fine, when I run the bot, there are no errors. The terminal is blank, but when I run this command, it doesn't work, it doesn't send a response, there is no error in the terminal also. Please Help..
Upvotes: 1
Views: 4731
Reputation: 56
There are few things wrong here.
This is basic stuff. Indent every line after the async def server(ctx):
line.
If you look at the documentation for guild, you can see that guild.text_channel_count
and guild.voice_channel_count
don't exist. Instead, you have to do len(guild.text_channels)
and len(guild.voice_channels)
instead.
On the second last line, I'm not sure why you have the {}
wrapped around icon_url = {ctx.message.author.avatar_url}
. So get rid of those.
Also, the url=embed.Empty
is completely unnecessary as well as it is the default value for embed.set_author()
(see here). So get rid of that.
ctx.guild.owner
by itself will give a Member
object, however as you put it in a f-string it will give an ugly representation (something like <discord.member_object_at_12391873123> or something idk
so instead do ctx.guild.owner.mention
so it would actually show the owner of the server in mention format (however since its in an embed it won't actually ping them)
In all, you should have:
@client.command()
async def server(ctx):
embed = discord.Embed(title=f"{ctx.guild.name} Info", description="Information of this Server", color=discord.Colour.blue())
embed.add_field(name='🆔Server ID', value=f"{ctx.guild.id}", inline=True)
embed.add_field(name='📆Created On', value=ctx.guild.created_at.strftime("%b %d %Y"), inline=True)
embed.add_field(name='👑Owner', value=f"{ctx.guild.owner.mention}", inline=True)
embed.add_field(name='👥Members', value=f'{ctx.guild.member_count} Members', inline=True)
embed.add_field(name='💬Channels', value=f'{len(ctx.guild.text_channels)} Text | {len(ctx.guild.voice_channels)} Voice', inline=True)
embed.add_field(name='🌎Region', value=f'{ctx.guild.region}', inline=True)
embed.set_thumbnail(url=ctx.guild.icon_url)
embed.set_footer(text="⭐ • Duo")
embed.set_author(name=f'{ctx.author.name}' icon_url=ctx.message.author.avatar_url
await ctx.send(embed=embed)
Edit: I forgot to mention that I have formatted your code a bit to adhere to PEP8 (as in no spaces around the =
in function calls, etc.)
Upvotes: 1
Reputation: 186
At first glance, you're not indenting properly. I also have never heard of url = embed.Empty
.
As an aside, I replaced the embed.set_author
line embed.set_author(name = f'{ctx.guild.name}', icon_url = {ctx.guild.icon_url})
with embed.set_author(name = f'{ctx.author.name}' icon_url = {ctx.message.author.avatar_url}
because it seemed to me like that was the line you wanted to display information about the author rather than the guild.
@client.command()
async def server(ctx):
embed = discord.Embed(title = f"{ctx.guild.name} Info", description = "Information of this Server", color = discord.Colour.blue())
embed.add_field(name = '🆔Server ID', value = f"{ctx.guild.id}", inline = True)
embed.add_field(name = '📆Created On', value = ctx.guild.created_at.strftime("%b %d %Y"), inline = True)
embed.add_field(name = '👑Owner', value = f"{ctx.guild.owner}", inline = True)
embed.add_field(name = '👥Members', value = f'{ctx.guild.member_count} Members', inline = True)
embed.add_field(name = '💬Channels', value = f'{ctx.guild.text_channel_count} Text | {ctx.guild.voice_channel_count} Voice', inline = True)
embed.add_field(name = '🌎Region', value = f'{ctx.guild.region}', inline = True)
embed.set_thumbnail(url = ctx.guild.icon_url)
embed.set_footer(text = "⭐ • Duo")
embed.set_author(name = f'{ctx.author.name}' icon_url = {ctx.message.author.avatar_url}
await ctx.send(embed=embed)
If resolving your indentation and removing url = embed.Empty
doesn't do the trick, then you'll have to run debug print statements line by line until you isolate the troublesome line.
Upvotes: 2