-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbatter.js
39 lines (38 loc) · 1.75 KB
/
batter.js
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
const interactionHandlers = require('../modules/interaction-handlers.js');
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('batter')
.setDescription('View slash lines and splits for a specified batter, or just who is batting right now.')
.addStringOption(option =>
option.setName('player')
.setDescription('An active player\'s name.')
.setRequired(false))
.addIntegerOption(option =>
option.setName('year')
.setDescription('Which season?')
.setRequired(false)
.setMinValue(new Date().getFullYear() - 10)
.setMaxValue(new Date().getFullYear()))
.addStringOption(option =>
option.setName('stat_type')
.setDescription('Regular Season (default), Postseason, or Spring Training?')
.setRequired(false)
.addChoices(
{ name: 'Regular Season', value: 'R' },
{ name: 'Postseason', value: 'P' },
{ name: 'Spring Training', value: 'S' }
)),
async execute (interaction) {
try {
await interactionHandlers.batterHandler(interaction);
} catch (e) {
console.error(e);
if (interaction.deferred && !interaction.replied) {
await interaction.followUp('There was an error processing this command. If it persists, please reach out to the developer.');
} else if (!interaction.replied) {
await interaction.reply('There was an error processing this command. If it persists, please reach out to the developer.');
}
}
}
};