You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
821 B
TypeScript
28 lines
821 B
TypeScript
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
|
|
}
|
|
}
|