import { PrismaClient } from '@prisma/client' import { SlashCommand, SlashCreator, CommandContext, MessageEmbed } from 'slash-create' export default class LeaderboardCommand extends SlashCommand { constructor(creator: SlashCreator) { super(creator, { name: 'leaderboard', description: 'see top 10 messages' }) } // eslint-disable-next-line @typescript-eslint/no-unused-vars async run(ctx: CommandContext) { const prisma = new PrismaClient() const users = await prisma.user.findMany({ where: { guild_id: ctx.guildID }, take: 10, orderBy: { messages: 'desc' } }) let st = '' for (const u of users) { let uu = await this.client.users.fetch(u.id) st += `${uu.username}#${uu.discriminator} - ${u.messages} message(s)\n` } return st } }