Lucas Tesch
Lucas Tesch

Reputation: 157

Display json python discord bot

I have a json file json that stores the xp and level of people on my server. I was doing a leaderboard to show the people who have the most xp on the server, but it is not working, could anyone help me?

Upvotes: 1

Views: 392

Answers (1)

Zenith
Zenith

Reputation: 245

You'll need to provide a string to send_message. If you want to have the people who have the most xp show up in order, and say five of them, you'd probably want to do something like

leaderboard = sorted(users, key=lambda x:users [x]["xp"])[5:]
await Bot.send_message(message.channel, "\n".join(leaderboard))

Upvotes: 1

Related Questions