Discord.py 机器人不会发送命令,我不知道为什么
Discord.py Bot won't send command and i don't know why
这是一个应该发送服务器信息嵌入的命令,由于某种原因它没有回复它,但我没有收到任何错误。这是我的代码,
@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)
您的代码中有一个小错字: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)
这是一个应该发送服务器信息嵌入的命令,由于某种原因它没有回复它,但我没有收到任何错误。这是我的代码,
@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)
您的代码中有一个小错字: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)