Reputation: 274
So I am trying to make a command, my code:
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 = '🥇'
elif len(ccc) == 2:
e = '🥈'
elif len(ccc) == 3:
e = '🥉'
else:
e = ''
embed.add_field(name=f'{len(ccc)}.{e}{m.name}#{m.discriminator}', value=f"> Rep points: **{v}**\n> Top: **{percs}**")
ccc.append(1)
embed.set_footer(text=f'Active at: ')
msg = await ctx.send(embed=embed)
But in this line:
async def global(ctx, top):
Python 'thinks' that I try to use global
keyword. But I just want it to become a command. How can I do this?
Upvotes: 0
Views: 39
Reputation: 201
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
Upvotes: 2