users = await read_data() to_count = {} total = [] for user in users: name = int(user) total_amount = users[user]["amount"] to_count[total_amount] = name total.append(total_amount)
資料排序
1
total = sorted(total, reverse = True)
元素添加
1 2 3 4 5 6 7 8 9
embed = discord.Embed(title = "這次的量", description = "將訂貨量排序後的結果呈現", color = 0x5568) embed.set_thumbnail(url = "https://www.formula-ai.com/wp-content/uploads/2020/09/python_or_java_meme.jpg") for i in total: userid = to_count[i] member = await bot.fetch_user(userid) name = member.name embed.add_field(name = f"{name}", value = f"您訂購的數量為{i}", inline = False) await ctx.send(embed = embed)