Python Discord.py添加命令

Python Discord.py添加命令,python,python-3.x,discord.py,Python,Python 3.x,Discord.py,所以我试图发出一个命令,我的代码: global_reps = {} @client.command() async def global(ctx, top): co2 = dict(sorted(global_reps.items(), key=operator.itemgetter(1), reverse=True)[:10]) print(co2) embed = discord.Embed( title = f'Global',

所以我试图发出一个命令,我的代码:

global_reps = {}
@client.command()
async def global(ctx, top):

        
    co2 = dict(sorted(global_reps.items(), key=operator.itemgetter(1), reverse=True)[:10])
    print(co2)
    embed = discord.Embed(
        title = f'Global',
        description = f'Reputation leaderboard',
        color = random.choice(cols),
        timestamp = ctx.message.created_at
    )
    ccc = [1]
    to = list(co2.values())
    top = sum(to)
    top = int(top)
        
    for k, v in co2.items():
        percs = '{:.0%}'.format(v/top)

        k = int(k)
        m = client.get_user(k)
        if len(ccc) == 1:
            e = 'There actually is a way to do this:

@client.command(name="global")
async def THIS_COULD_HAVE_ANY_NAME_NOW(ctx, top):
    # now define your command here
global_reps={}
@client.command()
异步def全局(ctx,顶部):
co2=dict(已排序(全局_reps.items(),key=operator.itemgetter(1),reverse=True)[:10])
打印(二氧化碳)
嵌入=不和谐。嵌入(
title=f'Global',
描述=f‘声誉排行榜’,
颜色=随机选择(cols),
timestamp=ctx.message.created\u在
)
ccc=[1]
to=列表(co2.values())
top=总和(至)
top=int(top)
对于二氧化碳中的k、v。项()
percs='{.0%}'。格式(v/top)
k=int(k)
m=客户端。获取用户(k)
如果len(ccc)==1:

实际上有一种方法可以做到这一点:


实际上有一种方法可以做到这一点: