diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index a6b6a1dd5..000000000 --- a/.gitpod.yml +++ /dev/null @@ -1,3 +0,0 @@ -tasks: - - init: yarn - command: yarn start diff --git a/discord.json b/discord.json index 44dce78cc..b178fe184 100644 --- a/discord.json +++ b/discord.json @@ -1,5 +1,6 @@ { "client_id": "1097673957865443370", + "client_id_dev": "1099063696015229078", "guild_id": "894784231677513819", "verify_channel": "909968131873726545", "verify_role": "909968395154358333", diff --git a/src/behaviors/interactionCreate.ts b/src/behaviors/interactionCreate.ts index e7f9a323d..4ba4e0afc 100644 --- a/src/behaviors/interactionCreate.ts +++ b/src/behaviors/interactionCreate.ts @@ -9,8 +9,10 @@ import { } from 'discord.js'; import { readdirSync } from 'fs'; import discord from '../../discord.json' assert { type: 'json' }; +import getClientId from '../utilities/getClientId.js'; export interface CommandRegistry { + disabled?: boolean; data: SlashCommandBuilder; execute: (interaction: Interaction) => void; } @@ -22,15 +24,18 @@ const rest = new REST().setToken(process.env.DISCORD_TOKEN!); for (const file of commandFolders) { const command = (await import(`../commands/${file}`)) as CommandRegistry; - commands.push(command.data.toJSON()); - commandCollection.set(command.data.name, command); + + if (!command.disabled) { + commands.push(command.data.toJSON()); + commandCollection.set(command.data.name, command); + } } try { console.log(`Started refreshing ${commands.length} command(s).`); const data = (await rest.put( - Routes.applicationGuildCommands(discord.client_id, discord.guild_id), + Routes.applicationGuildCommands(getClientId(), discord.guild_id), { body: commands }, )) as { length: number }; diff --git a/src/commands/stats.ts b/src/commands/stats.ts new file mode 100644 index 000000000..87abcbf96 --- /dev/null +++ b/src/commands/stats.ts @@ -0,0 +1,45 @@ +import { + CacheType, + ChatInputCommandInteraction, + SlashCommandBuilder, +} from 'discord.js'; +import { SERVERS } from '../constants/servers.js'; + +export async function execute( + interaction: ChatInputCommandInteraction, +) { + interaction.reply('YOU SUCK MORON GO PLAY ROBLOX'); +} + +export const data = new SlashCommandBuilder() + .setName('stats') + .setDescription("Gets the user's in-game statistics") + .addStringOption((option) => + option + .setName('server') + .setDescription('The Blitz server you are in') + .addChoices( + { name: SERVERS.com, value: 'com' }, + { name: SERVERS.eu, value: 'eu' }, + { name: SERVERS.asia, value: 'asia' }, + ) + .setRequired(true), + ) + .addStringOption((option) => + option + .setName('ign') + .setDescription('The username you use in Blitz') + .setRequired(true), + ) + .addStringOption((option) => + option + .setName('period') + .setDescription('The last number of days of stats') + .setChoices( + { name: '30 Days', value: '30' }, + { name: '60 Days', value: '60' }, + { name: '90 Days', value: '90' }, + { name: 'Career', value: 'career' }, + ) + .setRequired(true), + ); diff --git a/src/commands/verify.ts b/src/commands/verify.ts index 67311ed11..c5579b1ee 100644 --- a/src/commands/verify.ts +++ b/src/commands/verify.ts @@ -6,16 +6,17 @@ import { } from 'discord.js'; import fetch from 'node-fetch'; import discord from '../../discord.json' assert { type: 'json' }; +import { SERVERS } from '../constants/servers.js'; import AccountList from '../types/accountList.js'; -const SERVER_NAMES = { com: 'North America', eu: 'Europe', asia: 'Asia' }; +export const disabled = true; export async function execute( interaction: ChatInputCommandInteraction, ) { const ign = interaction.options.getString('ign')!; const server = interaction.options.getString('server')!; - const serverName = SERVER_NAMES[server as keyof typeof SERVER_NAMES]; + const serverName = SERVERS[server as keyof typeof SERVERS]; const players = (await fetch( `https://api.wotblitz.${server}/wotb/account/list/?application_id=${process.env.WARGAMING_APPLICATION_ID}&search=${ign}`, ).then((response) => response.json())) as AccountList; @@ -102,9 +103,9 @@ export const data = new SlashCommandBuilder() .setDescription('The Blitz server you are in') .setRequired(true) .addChoices( - { name: SERVER_NAMES.com, value: 'com' }, - { name: SERVER_NAMES.eu, value: 'eu' }, - { name: SERVER_NAMES.asia, value: 'asia' }, + { name: SERVERS.com, value: 'com' }, + { name: SERVERS.eu, value: 'eu' }, + { name: SERVERS.asia, value: 'asia' }, ), ) .addStringOption((option) => diff --git a/src/constants/servers.ts b/src/constants/servers.ts new file mode 100644 index 000000000..5b72dd0fa --- /dev/null +++ b/src/constants/servers.ts @@ -0,0 +1,5 @@ +export const SERVERS = { + com: 'North America', + eu: 'Europe', + asia: 'Asia', +}; diff --git a/src/index.ts b/src/index.ts index 62278be11..0b0093235 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ import { Client, GatewayIntentBits } from 'discord.js'; -import guildMemberAdd from './behaviors/guildMemberAdd.js'; import interactionCreate from './behaviors/interactionCreate.js'; import ready from './behaviors/ready.js'; import tokenRequirements from './utilities/tokenRequirements.js'; @@ -12,6 +11,6 @@ const client = new Client({ client.on('error', console.error); client.on('ready', ready); -client.on('guildMemberAdd', guildMemberAdd); +// client.on('guildMemberAdd', guildMemberAdd); client.on('interactionCreate', interactionCreate); client.login(process.env.DISCORD_TOKEN); diff --git a/src/utilities/getClientId.ts b/src/utilities/getClientId.ts new file mode 100644 index 000000000..0e2873bbd --- /dev/null +++ b/src/utilities/getClientId.ts @@ -0,0 +1,8 @@ +import { argv } from 'process'; +import discord from '../../discord.json' assert { type: 'json' }; + +const isDev = argv.includes('--dev'); + +export default function getClientId() { + return isDev ? discord.client_id_dev : discord.client_id; +}