From 423a8b8088fc8e86e788f20683a8b0270058b9d0 Mon Sep 17 00:00:00 2001 From: tresabhi Date: Wed, 5 Jul 2023 01:15:18 +0000 Subject: [PATCH] feat: added command suffix to commands --- src/commands/debug.ts | 4 +- src/commands/eligible.ts | 4 +- src/commands/evolution.tsx | 6 +- src/commands/help.ts | 4 +- src/commands/inactive.tsx | 4 +- .../{ownedtanks.tsx => ownedTanks.tsx} | 4 +- src/commands/ping.ts | 4 +- ...rachievements.ts => playerAchievements.ts} | 4 +- src/commands/{playerinfo.ts => playerInfo.ts} | 4 +- .../{searchclans.ts => searchClans.ts} | 4 +- .../{searchplayers.ts => searchPlayers.ts} | 4 +- .../{searchtanks.ts => searchTanks.ts} | 4 +- src/commands/stats.tsx | 6 +- src/commands/{statsfull.tsx => statsFull.tsx} | 4 +- src/commands/today.tsx | 4 +- src/commands/verify.ts | 4 +- src/events/interactionCreate/index.ts | 65 +++++++++---------- 17 files changed, 66 insertions(+), 67 deletions(-) rename src/commands/{ownedtanks.tsx => ownedTanks.tsx} (98%) rename src/commands/{playerachievements.ts => playerAchievements.ts} (97%) rename src/commands/{playerinfo.ts => playerInfo.ts} (97%) rename src/commands/{searchclans.ts => searchClans.ts} (97%) rename src/commands/{searchplayers.ts => searchPlayers.ts} (97%) rename src/commands/{searchtanks.ts => searchTanks.ts} (95%) rename src/commands/{statsfull.tsx => statsFull.tsx} (98%) diff --git a/src/commands/debug.ts b/src/commands/debug.ts index 9cfb93357..d3cb7805a 100644 --- a/src/commands/debug.ts +++ b/src/commands/debug.ts @@ -10,7 +10,7 @@ import { CommandRegistry } from '../events/interactionCreate/index.js'; const executionStart = new Date().getTime(); -export default { +export const debugCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -42,4 +42,4 @@ export default { ]), ); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/eligible.ts b/src/commands/eligible.ts index 30ec318cf..48312b13f 100644 --- a/src/commands/eligible.ts +++ b/src/commands/eligible.ts @@ -23,7 +23,7 @@ export const SKILLED_CLANS: Record = { SMRI: 'Samurai', }; -export default { +export const eligibleCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: false, @@ -169,4 +169,4 @@ export default { return (isEligible ? embedPositive : embedNegative)(title, body); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index 020c60fd5..25e7274dc 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -18,9 +18,9 @@ import evolution from '../renderers/evolution.js'; import { StatType } from '../renderers/statsfull.js'; import { AccountInfo } from '../types/accountInfo.js'; -export default { +export const evolutionCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( @@ -83,4 +83,4 @@ export default { parseInt(url.searchParams.get('tankId')!), ); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/help.ts b/src/commands/help.ts index 2ce447da2..408fe78b7 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -8,7 +8,7 @@ import { publicCommands, } from '../events/interactionCreate/index.js'; -export default { +export const helpCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -33,4 +33,4 @@ export default { )}\n\n*I am a new bot; I may make mistakes and go offline unexpectedly from time to time.*`, ); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/inactive.tsx b/src/commands/inactive.tsx index b5687f3b6..987f6568d 100644 --- a/src/commands/inactive.tsx +++ b/src/commands/inactive.tsx @@ -16,7 +16,7 @@ import { ClanInfo } from '../types/clanInfo.js'; const DEFAULT_THRESHOLD = 7; -export default { +export const inactiveCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -85,4 +85,4 @@ export default { }, autocomplete: autocompleteClan, -} satisfies CommandRegistry; +}; diff --git a/src/commands/ownedtanks.tsx b/src/commands/ownedTanks.tsx similarity index 98% rename from src/commands/ownedtanks.tsx rename to src/commands/ownedTanks.tsx index a7d9ffd59..66dd7e816 100644 --- a/src/commands/ownedtanks.tsx +++ b/src/commands/ownedTanks.tsx @@ -41,7 +41,7 @@ const COMP_TANKS = [ 6753, // type 71 ]; -export default { +export const ownedTanksCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -121,4 +121,4 @@ export default { }, autocomplete: autocompleteUsername, -} satisfies CommandRegistry; +}; diff --git a/src/commands/ping.ts b/src/commands/ping.ts index bcff65f19..71e2bde94 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -1,7 +1,7 @@ import { SlashCommandBuilder } from 'discord.js'; import { CommandRegistry } from '../events/interactionCreate/index.js'; -export default { +export const pingCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -30,4 +30,4 @@ export default { const executionTime = Date.now() - executionStart; interaction.editReply(`Pong 🏓 - ${executionTime}ms`); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/playerachievements.ts b/src/commands/playerAchievements.ts similarity index 97% rename from src/commands/playerachievements.ts rename to src/commands/playerAchievements.ts index 242826988..a0a6d41d9 100644 --- a/src/commands/playerachievements.ts +++ b/src/commands/playerAchievements.ts @@ -16,7 +16,7 @@ import { AccountInfo } from '../types/accountInfo.js'; type SortBy = 'name' | 'count'; -export default { +export const playerAchievementsCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -75,4 +75,4 @@ export default { }, autocomplete: autocompleteUsername, -} satisfies CommandRegistry; +}; diff --git a/src/commands/playerinfo.ts b/src/commands/playerInfo.ts similarity index 97% rename from src/commands/playerinfo.ts rename to src/commands/playerInfo.ts index 7e34552e3..d33e2f06a 100644 --- a/src/commands/playerinfo.ts +++ b/src/commands/playerInfo.ts @@ -10,7 +10,7 @@ import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; import { CommandRegistry } from '../events/interactionCreate/index.js'; import { AccountInfo } from '../types/accountInfo.js'; -export default { +export const playerInfoCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -57,4 +57,4 @@ export default { }, autocomplete: autocompleteUsername, -} satisfies CommandRegistry; +}; diff --git a/src/commands/searchclans.ts b/src/commands/searchClans.ts similarity index 97% rename from src/commands/searchclans.ts rename to src/commands/searchClans.ts index 56244b025..64980acde 100644 --- a/src/commands/searchclans.ts +++ b/src/commands/searchClans.ts @@ -9,7 +9,7 @@ import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; import { CommandRegistry } from '../events/interactionCreate/index.js'; import { ClanList } from '../types/clanList.js'; -export default { +export const searchClansCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -44,4 +44,4 @@ export default { .join('\n')}\n\`\`\``, ); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/searchplayers.ts b/src/commands/searchPlayers.ts similarity index 97% rename from src/commands/searchplayers.ts rename to src/commands/searchPlayers.ts index fba77980e..4db2f37e4 100644 --- a/src/commands/searchplayers.ts +++ b/src/commands/searchPlayers.ts @@ -10,7 +10,7 @@ import { WARGAMING_APPLICATION_ID } from '../core/node/arguments.js'; import { CommandRegistry } from '../events/interactionCreate/index.js'; import { AccountList } from '../types/accountList.js'; -export default { +export const searchPlayersCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -52,4 +52,4 @@ export default { }\`\`\``, ); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/searchtanks.ts b/src/commands/searchTanks.ts similarity index 95% rename from src/commands/searchtanks.ts rename to src/commands/searchTanks.ts index 76e4157c3..1bb160254 100644 --- a/src/commands/searchtanks.ts +++ b/src/commands/searchTanks.ts @@ -6,7 +6,7 @@ import addTankChoices from '../core/discord/addTankChoices.js'; import embedInfo from '../core/discord/embedInfo.js'; import { CommandRegistry } from '../events/interactionCreate/index.js'; -export default { +export const searchTanksCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -37,4 +37,4 @@ export default { : `\`\`\`\n${results.join('\n')}\n\`\`\``, ); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index 4f29fbda2..e7b4d47a8 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -18,9 +18,9 @@ import stats from '../renderers/stats.js'; import { StatType } from '../renderers/statsfull.js'; import { AccountInfo } from '../types/accountInfo.js'; -export default { +export const statsCommand: CommandRegistry = { inProduction: true, - inDevelopment: true, + inDevelopment: false, inPublic: true, command: addStatTypeSubCommandGroups( @@ -81,4 +81,4 @@ export default { parseInt(url.searchParams.get('tankId')!), ); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/statsfull.tsx b/src/commands/statsFull.tsx similarity index 98% rename from src/commands/statsfull.tsx rename to src/commands/statsFull.tsx index 1683abb8d..501e6e511 100644 --- a/src/commands/statsfull.tsx +++ b/src/commands/statsFull.tsx @@ -17,7 +17,7 @@ import { CommandRegistry } from '../events/interactionCreate/index.js'; import statsfull, { StatType } from '../renderers/statsfull.js'; import { AccountInfo } from '../types/accountInfo.js'; -export default { +export const statsFullCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -80,4 +80,4 @@ export default { parseInt(url.searchParams.get('tankId')!), ); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/today.tsx b/src/commands/today.tsx index 950297142..d2a166afd 100644 --- a/src/commands/today.tsx +++ b/src/commands/today.tsx @@ -12,7 +12,7 @@ import { CommandRegistry } from '../events/interactionCreate/index.js'; import today from '../renderers/today.js'; import { AccountInfo } from '../types/accountInfo.js'; -export default { +export const todayCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -49,4 +49,4 @@ export default { return await today(player); }, -} satisfies CommandRegistry; +}; diff --git a/src/commands/verify.ts b/src/commands/verify.ts index 5a3e3402c..c3cfb4b59 100644 --- a/src/commands/verify.ts +++ b/src/commands/verify.ts @@ -12,7 +12,7 @@ import { CommandRegistry } from '../events/interactionCreate/index.js'; import { AccountInfo } from '../types/accountInfo.js'; import { PlayerClanData } from '../types/playerClanData.js'; -export default { +export const verifyCommand: CommandRegistry = { inProduction: true, inDevelopment: false, inPublic: true, @@ -80,4 +80,4 @@ export default { }, autocomplete: autocompleteUsername, -} satisfies CommandRegistry; +}; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 92e145979..49b3ec1e7 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -13,22 +13,22 @@ import { SlashCommandSubcommandsOnlyBuilder, } from 'discord.js'; import discord from '../../../discord.json' assert { type: 'json' }; -import debug from '../../commands/debug.js'; -import eligible from '../../commands/eligible.js'; -import evolution from '../../commands/evolution.js'; -import help from '../../commands/help.js'; -import inactive from '../../commands/inactive.js'; -import ownedtanks from '../../commands/ownedtanks.js'; -import ping from '../../commands/ping.js'; -import playerachievements from '../../commands/playerachievements.js'; -import playerinfo from '../../commands/playerinfo.js'; -import searchclans from '../../commands/searchclans.js'; -import searchplayers from '../../commands/searchplayers.js'; -import searchtanks from '../../commands/searchtanks.js'; -import stats from '../../commands/stats.js'; -import statsfull from '../../commands/statsfull.js'; -import today from '../../commands/today.js'; -import verify from '../../commands/verify.js'; +import { debugCommand } from '../../commands/debug.js'; +import { eligibleCommand } from '../../commands/eligible.js'; +import { evolutionCommand } from '../../commands/evolution.js'; +import { helpCommand } from '../../commands/help.js'; +import { inactiveCommand } from '../../commands/inactive.js'; +import { ownedTanksCommand } from '../../commands/ownedTanks.js'; +import { pingCommand } from '../../commands/ping.js'; +import { playerAchievementsCommand } from '../../commands/playerAchievements.js'; +import { playerInfoCommand } from '../../commands/playerInfo.js'; +import { searchClansCommand } from '../../commands/searchClans.js'; +import { searchPlayersCommand } from '../../commands/searchPlayers.js'; +import { searchTanksCommand } from '../../commands/searchTanks.js'; +import { statsCommand } from '../../commands/stats.js'; +import { statsFullCommand } from '../../commands/statsFull.js'; +import { todayCommand } from '../../commands/today.js'; +import { verifyCommand } from '../../commands/verify.js'; import { DISCORD_TOKEN } from '../../core/node/arguments.js'; import getClientId from '../../core/node/getClientId.js'; import isDev from '../../core/node/isDev.js'; @@ -72,26 +72,25 @@ const rest = new REST().setToken(DISCORD_TOKEN); export const commands: Record = ( [ - debug, - eligible, - help, - inactive, - ownedtanks, - playerachievements, - playerinfo, - searchclans, - searchplayers, - searchtanks, - statsfull, - today, - verify, - ping, - evolution, - stats, + debugCommand, + eligibleCommand, + helpCommand, + inactiveCommand, + ownedTanksCommand, + playerAchievementsCommand, + playerInfoCommand, + searchClansCommand, + searchPlayersCommand, + searchTanksCommand, + statsFullCommand, + todayCommand, + verifyCommand, + pingCommand, + evolutionCommand, + statsCommand, ] as CommandRegistry[] ).reduce((accumulator, registry) => { if (isDev()) registry.command.setDefaultMemberPermissions(0); - return { ...accumulator, [registry.command.name]: registry }; }, {});