这是一个应该发送嵌入服务器信息的命令,由于某种原因它没有回复它,但是我没有收到任何错误。这是我的代码,
@client.command()
async def serverinfo(ctx):
embed = discord.Embed(color=discord.Color.green())
embed.set_author(name=f'{ctx.guild_name} Server Info')
embed.set_thumbnail(url=ctx.guild.icon_url)
embed.add_field(name="Server Name: ", value=ctx.guild.name, inline=False)
embed.add_field(name="Server ID: ", value=ctx.guild.id, inline=False)
embed.add_field(name="Members: ", value=ctx.guild.member_count, inline=False)
embed.add_field(name="Owner: ", value=ctx.guild.owner, inline=False)
embed.add_field(name="Region: ", value=ctx.guild.region, inline=False)
embed.add_field(name="Created: ", value=ctx.guild.created_at.strftime("%a, %#d %B %Y, %I:%M %p GMT"))
await ctx.send(embed=embed)
答案 0 :(得分:0)
您的代码中有一个小的错字:ctx.guild_name
。您使用的是“ _”而不是“。”
因此,您需要将ctx.guild_name
更改为ctx.guild.name
。
如果您进行了更改,它将起作用:
@client.command()
async def serverinfo(ctx):
embed = discord.Embed(color=discord.Color.green())
embed.set_author(name=f'{ctx.guild.name} Server Info')
embed.set_thumbnail(url=ctx.guild.icon_url)
embed.add_field(name="Server Name: ", value=ctx.guild.name, inline=False)
embed.add_field(name="Server ID: ", value=ctx.guild.id, inline=False)
embed.add_field(name="Members: ", value=ctx.guild.member_count, inline=False)
embed.add_field(name="Owner: ", value=ctx.guild.owner, inline=False)
embed.add_field(name="Region: ", value=ctx.guild.region, inline=False)
embed.add_field(name="Created: ", value=ctx.guild.created_at.strftime("%a, %#d %B %Y, %I:%M %p GMT"))
await ctx.send(embed=embed)