forked from Balatro-Multiplayer/Botlatro-Multiplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.ts
More file actions
54 lines (53 loc) · 1.71 KB
/
stats.ts
File metadata and controls
54 lines (53 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import viewStats from '../queues/statsQueue'
import {
AutocompleteInteraction,
ChatInputCommandInteraction,
SlashCommandBuilder,
} from 'discord.js'
import { getQueueNames } from 'utils/queryDB'
export default {
data: new SlashCommandBuilder()
.setName('stats')
.setDescription('view stats')
.addSubcommand((sub) =>
sub
.setName('queue')
.setDescription('View your queue stats.')
.addStringOption((option) =>
option
.setName('queue-name')
.setDescription('The queue name to view stats for')
.setRequired(true)
.setAutocomplete(true),
)
.addUserOption((option) =>
option
.setName('user')
.setDescription('The user to view stats for (defaults to yourself)')
.setRequired(false),
)
.addStringOption((option) =>
option
.setName('by-date')
.setDescription('Sort the stats by date')
.addChoices([{ name: 'yes', value: 'yes' }])
.setRequired(false),
),
),
async execute(interaction: ChatInputCommandInteraction) {
if (interaction.options.getSubcommand() === 'queue') {
await viewStats.execute(interaction)
}
},
async autocomplete(interaction: AutocompleteInteraction) {
const currentValue = interaction.options.getFocused()
const queueNames = await getQueueNames()
const filteredQueueNames = queueNames.filter((name) =>
name.toLowerCase().includes(currentValue.toLowerCase()),
)
await interaction.respond(
filteredQueueNames.map((name) => ({ name, value: name })).slice(0, 25),
)
},
}
// this supercommand should only be usable by everyone+