我做了一个状态命令,但它不起作用

时间:2021-04-04 19:30:43

标签: python-3.x

我做了这个代码:

@client.command()
async def status(ctx):
       em = discord.Embed(
        title = 'Status',
        color = 0x900ff,
        description = "",
        timestamp = ctx.message.created_at

    )
    em.add_field(name = "Online?", value = "Yes", inline=False)
    em.add_field(name = "Ping?", value = f"{round(client.latency * 1000)}ms", inline=False)
    em.set_author(name = "Brobotel V2 is Bacc", url ="", icon_url="https://i.imgur.com/mc9Gcdp.jpg")
    em.set_footer(text = f'Invoked by: @{ctx.author}!')

    await ctx.send(embed = em)

但它给了我一个错误:

error

1 个答案:

答案 0 :(得分:0)

你的 em = discord.Embed( 应该像下面的例子一样缩进

import discord
from discord.ext import commands
client =  commands.Bot(command_prefix='$')
@client.command()
async def status(ctx):
    em = discord.Embed(
        title = 'Status',
        color = 0x900ff,
        description = "",
        timestamp = ctx.message.created_at

    )
    em.add_field(name = "Online?", value = "Yes", inline=False)
    em.add_field(name = "Ping?", value = f"{round(client.latency * 1000)}ms", inline=False)
    em.set_author(name = "Brobotel V2 is Bacc", url ="", icon_url="https://i.imgur.com/mc9Gcdp.jpg")
    em.set_footer(text = f'Invoked by: @{ctx.author}!')

    await ctx.send(embed = em)