From 3f83fffade3a92ee14a3e422249ef7a9a447ca61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 21 Jul 2024 19:41:37 -0500 Subject: [PATCH] feat: remove legacy bot code --- discord.json | 12 +- src/commands/about.ts | 4 - src/commands/breakdown/index.tsx | 3 - src/commands/clanEvent.ts | 93 -------- src/commands/debug.ts | 3 - src/commands/eligible.ts | 205 ------------------ src/commands/evolution.tsx | 3 - src/commands/fullStats.tsx | 3 - src/commands/inactive.tsx | 3 - src/commands/link.tsx | 29 --- src/commands/ownedTanks.tsx | 3 - src/commands/permissions.ts | 3 - src/commands/ping.ts | 2 - src/commands/playerAchievements.ts | 80 ------- src/commands/playerInfo.ts | 3 - src/commands/rating.tsx | 3 - src/commands/ratingLeaderboard.tsx | 3 - src/commands/replay.tsx | 2 - src/commands/research.tsx | 3 - src/commands/searchClans.ts | 3 - src/commands/searchPlayers.ts | 3 - src/commands/searchTanks.ts | 51 ----- src/commands/stats.tsx | 3 - src/commands/today.ts | 3 - src/core/discord/client.ts | 2 - src/events/guildMemberAdd.ts | 15 -- .../handlers/chatInputCommand.ts | 15 -- src/events/interactionCreate/index.ts | 39 +--- 28 files changed, 5 insertions(+), 589 deletions(-) delete mode 100644 src/commands/clanEvent.ts delete mode 100644 src/commands/eligible.ts delete mode 100644 src/commands/playerAchievements.ts delete mode 100644 src/commands/searchTanks.ts delete mode 100644 src/events/guildMemberAdd.ts diff --git a/discord.json b/discord.json index d3ffa5749..4420687dc 100644 --- a/discord.json +++ b/discord.json @@ -1,14 +1,4 @@ { "client_id": "1097673957865443370", - "client_id_dev": "1099063696015229078", - - "sklld_guild_id": "894784231677513819", - "sklld_verify_channel": "909968131873726545", - "sklld_verify_role": "909968395154358333", - "sklld_peasant_role": "896878529512370228", - - "tres_guild_id": "734786591205359697", - "tres_log_channel": "1109262265850544148", - - "test_guild_id": "1124729294829142116" + "client_id_dev": "1099063696015229078" } diff --git a/src/commands/about.ts b/src/commands/about.ts index 52c7a53bc..240e63b24 100644 --- a/src/commands/about.ts +++ b/src/commands/about.ts @@ -21,9 +21,6 @@ const DOCS: Record = { export const aboutCommand = new Promise(async (resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('about', [ { subcommand: 'commands' }, ...subcommands.map((subcommand) => ({ subcommand })), @@ -37,7 +34,6 @@ export const aboutCommand = new Promise(async (resolve) => { return t`bot.commands.about.subcommands.commands.body${( await Promise.all(COMMANDS_RAW) ) - .filter((registry) => registry.inPublic && registry.inProduction) .sort((a, b) => (a.command.name_localizations?.[interaction.locale] ?? a.command.name) < diff --git a/src/commands/breakdown/index.tsx b/src/commands/breakdown/index.tsx index dee2736c8..5acd2237a 100644 --- a/src/commands/breakdown/index.tsx +++ b/src/commands/breakdown/index.tsx @@ -19,9 +19,6 @@ import { renderBreakdown } from './render'; export const breakdownCommand = new Promise( async (resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: await addPeriodicFilterOptions( createLocalizedCommand('breakdown'), (option) => option.addStringOption(addUsernameChoices), diff --git a/src/commands/clanEvent.ts b/src/commands/clanEvent.ts deleted file mode 100644 index 8c869e593..000000000 --- a/src/commands/clanEvent.ts +++ /dev/null @@ -1,93 +0,0 @@ -// _____ _____ _ _ _ _ _____ ____ __ __ ______ ____ _____ _ __ -// |_ _| / ____| | | | /\ | | | | / ____/ __ \| \/ | ____| | _ \ /\ / ____| |/ / -// | | | (___ | |__| | / \ | | | | | | | | | | \ / | |__ | |_) | / \ | | | ' / -// | | \___ \| __ | / /\ \ | | | | | | | | | | |\/| | __| | _ < / /\ \| | | < -// _| |_ ____) | | | |/ ____ \| |____| |____ | |___| |__| | | | | |____ | |_) / ____ \ |____| . \ -// |_____| |_____/|_| |_/_/ \_\______|______| \_____\____/|_| |_|______| |____/_/ \_\_____|_|\_\ - -// import { SlashCommandBuilder, escapeMarkdown } from 'discord.js'; -// import markdownEscape from 'markdown-escape'; -// import { getAccountAchievements } from '../core/blitz/getAccountAchievements'; -// import { getAccountInfo } from '../core/blitz/getAccountInfo'; -// import { getClanInfo } from '../core/blitz/getClanInfo'; -// import { PlayerHistoriesRaw } from '../LEGACY_core/blitzstars/getPlayerHistories'; -// import getTimeDaysAgo from '../LEGACY_core/blitzstars/getTimeDaysAgo'; -// import addClanChoices from '../LEGACY_core/discord/addClanChoices'; -// import autocompleteClan from '../LEGACY_core/discord/autocompleteClan'; -// import embedWarning from '../LEGACY_core/discord/embedWarning'; -// import resolveClanFromCommand from '../LEGACY_core/discord/resolveClanFromCommand'; -// import { CommandRegistry } from '../events/interactionCreate'; - -// export const clanEventCommand: CommandRegistry = { -// inProduction: false, -// inPublic: true, - -// command: new SlashCommandBuilder() -// .setName('clan-event') -// .setDescription('Lists all inactive players') -// .addStringOption(addClanChoices), - -// async handler(interaction) { -// const { region, id } = await resolveClanFromCommand(interaction); -// const clan = await getClanInfo(region, id); -// const [players, achievements, previousJointVictories] = await Promise.all([ -// getAccountInfo(region, clan.members_ids), -// getAccountAchievements(region, clan.members_ids), -// Promise.all( -// clan.members_ids.map((id) => -// fetch(`https://www.blitzstars.com/api/playerstats/${id}`) -// .then((response) => response.json() as Promise) -// .then((data) => ({ -// id, -// jointVictory: data[0]?.achievements.jointVictoryCount as -// | number -// | undefined, -// })), -// ), -// ).then((data) => -// data.reduce>( -// (accumulator, value) => ({ -// ...accumulator, -// [value.id]: value.jointVictory, -// }), -// {}, -// ), -// ), -// ]); -// const jointVictories = clan.members_ids.map((id) => ({ -// id, -// joinVictory: -// players[id].last_battle_time > getTimeDaysAgo(region, 1) -// ? previousJointVictories[id] === undefined -// ? 0 -// : achievements[id].max_series.jointVictory - -// previousJointVictories[id]! -// : 0, -// })); - -// return [ -// `# ${escapeMarkdown(clan.name)} [${escapeMarkdown( -// clan.tag, -// )}]'s platoon wins today: ${( -// jointVictories.reduce( -// (accumulator, { joinVictory }) => accumulator + joinVictory, -// 0, -// ) / 2 -// ).toFixed(0)}\n${jointVictories -// .filter(({ joinVictory }) => joinVictory) -// .sort((a, b) => b.joinVictory - a.joinVictory) -// .map( -// ({ id, joinVictory }) => -// `- ${markdownEscape(players[id].nickname)}: ${joinVictory}`, -// ) -// .join('\n')}`, - -// embedWarning( -// 'This is an approximation!', -// "Wargaming provides very little information about platoons publicly. Caveats:\n- Players in two different clans platooning artificially inflates the total count\n- Game-mode battles aren't counted since Wargaming doesn't publicly share that data\n- This command is also subject to Blitzkit's reset times (use `/about timezones` for more info)", -// ), -// ]; -// }, - -// autocomplete: autocompleteClan, -// }; diff --git a/src/commands/debug.ts b/src/commands/debug.ts index 57452999b..e2d99f541 100644 --- a/src/commands/debug.ts +++ b/src/commands/debug.ts @@ -8,9 +8,6 @@ const executionStart = new Date().getTime(); export const debugCommand = new Promise((resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('debug'), async handler(interaction) { diff --git a/src/commands/eligible.ts b/src/commands/eligible.ts deleted file mode 100644 index 197e1301a..000000000 --- a/src/commands/eligible.ts +++ /dev/null @@ -1,205 +0,0 @@ -// _____ _____ _ _ _ _ _____ ____ __ __ ______ ____ _____ _ __ -// |_ _| / ____| | | | /\ | | | | / ____/ __ \| \/ | ____| | _ \ /\ / ____| |/ / -// | | | (___ | |__| | / \ | | | | | | | | | | \ / | |__ | |_) | / \ | | | ' / -// | | \___ \| __ | / /\ \ | | | | | | | | | | |\/| | __| | _ < / /\ \| | | < -// _| |_ ____) | | | |/ ____ \| |____| |____ | |___| |__| | | | | |____ | |_) / ____ \ |____| . \ -// |_____| |_____/|_| |_/_/ \_\______|______| \_____\____/|_| |_|______| |____/_/ \_\_____|_|\_\ - -// import { SlashCommandBuilder } from 'discord.js'; -// import { getAccountInfo } from '../core/blitz/getAccountInfo'; -// import getPeriodNow from '../core/blitzkit/getPeriodNow'; -// import getTimeDaysAgo from '../core/blitzkit/getTimeDaysAgo'; -// import { tankDefinitions } from '../core/blitzkit/tankDefinitions'; -// import getStatsInPeriod from '../core/blitzstars/getStatsInPeriod'; -// import { tankAverages } from '../core/blitzstars/tankAverages'; -// import addUsernameChoices from '../core/discord/addUsernameChoices'; -// import embedNegative from '../core/discord/embedNegative'; -// import embedPositive from '../core/discord/embedPositive'; -// import markdownTable, { TableInput } from '../core/discord/markdownTable'; -// import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand'; -// import calculateWN8 from '../core/statistics/calculateWN8'; -// import sumStats from '../core/statistics/sumStats'; -// import { CommandRegistry } from '../events/interactionCreate'; -// import { PossiblyPromise } from '../types/possiblyPromise'; - -// export type SkilledClan = 'SKLLD' | 'SMRI'; - -// export const SKILLED_CLANS: Record = { -// SKLLD: 'Skilled', -// SMRI: 'Samurai', -// }; - -// export const eligibleCommand: CommandRegistry = { -// inProduction: true, -// inPublic: false, - -// command: new SlashCommandBuilder() -// .setName('eligible') -// .setDescription('Checks eligibility for any Skilled clan') -// .addStringOption((option) => -// option -// .setName('clan') -// .setDescription('The clan to check') -// .setChoices( -// { -// name: SKILLED_CLANS.SKLLD, -// value: 'SKLLD' satisfies SkilledClan, -// }, -// { name: SKILLED_CLANS.SMRI, value: 'SMRI' satisfies SkilledClan }, -// ) -// .setRequired(true), -// ) -// .addStringOption(addUsernameChoices), - -// async handler(interaction) { -// const clan = interaction.options.getString('clan') as SkilledClan; -// const { id, region: region } = await resolvePlayerFromCommand(interaction); -// const accountInfo = await getAccountInfo(region, id); -// const problems: TableInput = []; -// const title = `${accountInfo.nickname}'s eligibility for ${SKILLED_CLANS[clan]}`; -// let isEligible = false; -// let body = ''; - -// if (clan === 'SKLLD') { -// const { diff: diffed } = await getStatsInPeriod( -// region, -// id, -// getTimeDaysAgo(region, 30), -// getPeriodNow(), -// ); -// const entries = Object.entries(diffed); -// const stats = sumStats(entries.map(([, stats]) => stats)); -// const averageTier = -// (await entries.reduce>( -// async (accumulator, [tankIdString, stats]) => { -// const tankId = parseInt(tankIdString); -// const tankDefinition = (await tankDefinitions)[tankId]; - -// if (!tankDefinition) return accumulator; - -// const tankTier = tankDefinition.tier; - -// return (await accumulator) + tankTier * stats.battles; -// }, -// 0, -// )) / -// (await entries.reduce>( -// async (accumulator, [tankIdString, stats]) => { -// const tankId = parseInt(tankIdString); -// const tankDefinition = (await tankDefinitions)[tankId]; - -// if (!tankDefinition) return accumulator; - -// return stats.battles; -// }, -// 0, -// )); -// const WN8 = -// (await entries.reduce>( -// async (accumulator, [tankIdString, stats]) => { -// const tankId = parseInt(tankIdString); - -// // edge case where new tanks don't have averages -// if ((await tankAverages)[tankId]) { -// const tankWN8 = calculateWN8( -// (await tankAverages)[tankId].all, -// stats, -// ); - -// if (isNaN(tankWN8)) return accumulator; -// return (await accumulator) + tankWN8 * stats.battles; -// } else return accumulator; -// }, -// 0, -// )) / stats.battles; -// const tier10Damage = -// (await entries.reduce>( -// async (accumulator, [tankIdString, stats]) => { -// const tankId = parseInt(tankIdString); - -// if ((await tankDefinitions)[tankId]?.tier === 10) { -// const tankStats = diffed[tankId]; -// return (await accumulator) + tankStats.damage_dealt; -// } else return accumulator; -// }, -// 0, -// )) / -// (await entries.reduce>( -// async (accumulator, [tankIdString, stats]) => { -// const tankId = parseInt(tankIdString); - -// if ((await tankDefinitions)[tankId]?.tier === 10) { -// const tankStats = diffed[tankId]; -// return (await accumulator) + tankStats.battles; -// } else return accumulator; -// }, -// 0, -// )); - -// if (stats.battles < 126) { -// problems.push(['Battles', `${stats.battles} (${stats.battles - 126})`]); -// } -// if (averageTier < 8) { -// problems.push([ -// 'Average tier', -// `${averageTier.toFixed(2)} (${(averageTier - 8).toFixed(2)})`, -// ]); -// } -// if (stats.wins / stats.battles < 0.6) { -// problems.push([ -// 'Winrate', -// `${(100 * (stats.wins / stats.battles)).toFixed(2)}% (${( -// 100 * -// (stats.wins / stats.battles - 0.6) -// ).toFixed(2)}%)`, -// ]); -// } -// if (WN8 < 2450) { -// problems.push([ -// 'WN8', -// `${WN8.toFixed(0)} (${(WN8 - 2450).toFixed(0)})`, -// ]); -// } -// if (tier10Damage < 1250) { -// problems.push([ -// 'Tier 10 damage', -// `${tier10Damage.toFixed(0)} (${tier10Damage - 1250})`, -// ]); -// } - -// isEligible = problems.length === 0; -// body = isEligible -// ? 'Player is fully eligible.' -// : `Player is not eligible. Shortcomings in 30-day statistics:\n\n${markdownTable( -// problems, -// )}`; -// } else if (clan === 'SMRI') { -// const stats = accountInfo.statistics.all; - -// if (stats.battles < 1500) { -// problems.push([ -// 'Battles', -// `${stats.battles} (${stats.battles - 1500})`, -// ]); -// } -// if (stats.wins / stats.battles <= 0.53) { -// problems.push([ -// 'Winrate', -// `${(100 * (stats.wins / stats.battles)).toFixed(2)}% (${( -// 100 * -// (stats.wins / stats.battles - 0.53) -// ).toFixed(2)}%)`, -// ]); -// } - -// isEligible = problems.length === 0; -// body = isEligible -// ? 'Player is fully eligible.' -// : `Player is not eligible. Shortcomings in career statistics:\n\n${markdownTable( -// problems, -// )}`; -// } - -// return (isEligible ? embedPositive : embedNegative)(title, body); -// }, -// }; diff --git a/src/commands/evolution.tsx b/src/commands/evolution.tsx index 79d29915c..32a5b2eea 100644 --- a/src/commands/evolution.tsx +++ b/src/commands/evolution.tsx @@ -110,9 +110,6 @@ async function render( export const evolutionCommand = new Promise( async (resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('evolution', [ { group: 'player', diff --git a/src/commands/fullStats.tsx b/src/commands/fullStats.tsx index 6ccf65a2b..0bb317aa5 100644 --- a/src/commands/fullStats.tsx +++ b/src/commands/fullStats.tsx @@ -81,9 +81,6 @@ async function render( export const fullStatsCommand = new Promise( async (resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: await addPeriodicFilterOptions( createLocalizedCommand('full-stats'), (option) => option.addStringOption(addUsernameChoices), diff --git a/src/commands/inactive.tsx b/src/commands/inactive.tsx index 0c74df574..4b78ea910 100644 --- a/src/commands/inactive.tsx +++ b/src/commands/inactive.tsx @@ -17,9 +17,6 @@ const DEFAULT_THRESHOLD = 7; export const inactiveCommand = new Promise((resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('inactive') .addStringOption(addClanChoices) .addNumberOption((option) => { diff --git a/src/commands/link.tsx b/src/commands/link.tsx index dc9e97235..159b9b107 100644 --- a/src/commands/link.tsx +++ b/src/commands/link.tsx @@ -1,7 +1,4 @@ import { teal } from '@radix-ui/colors'; -import { GuildMemberRoleManager } from 'discord.js'; -import markdownEscape from 'markdown-escape'; -import discord from '../../discord.json' assert { type: 'json' }; import { Glow } from '../components/AllStatsOverview/components/HeroStat/components/Glow'; import CommandWrapper from '../components/CommandWrapper'; import { getAccountInfo } from '../core/blitz/getAccountInfo'; @@ -11,7 +8,6 @@ import addUsernameChoices from '../core/discord/addUsernameChoices'; import autocompleteUsername from '../core/discord/autocompleteUsername'; import { createLocalizedCommand } from '../core/discord/createLocalizedCommand'; import embedInfo from '../core/discord/embedInfo'; -import embedNegative from '../core/discord/embedNegative'; import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand'; import { translator } from '../core/localization/translator'; import { CommandRegistry } from '../events/interactionCreate'; @@ -19,9 +15,6 @@ import { theme } from '../stitches.config'; export const verifyCommand = new Promise((resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('link').addStringOption((option) => addUsernameChoices(option).setRequired(true), ), @@ -35,28 +28,6 @@ export const verifyCommand = new Promise((resolve) => { await linkBlitzAndDiscord(discordId, id); - if (interaction.guildId === discord.sklld_guild_id) { - if (!interaction.guild?.members.me?.permissions.has('ManageRoles')) { - return embedNegative( - translate(translate('bot.commands.link.body.no_role_permissions'), [ - markdownEscape(interaction.user.username), - ]), - translate( - translate( - 'bot.commands.link.body.no_role_permissions.description', - ), - ), - ); - } - - await (interaction.member!.roles as GuildMemberRoleManager).remove( - discord.sklld_verify_role, - ); - await (interaction.member!.roles as GuildMemberRoleManager).add( - discord.sklld_peasant_role, - ); - } - return [
((resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('owned-tanks') .addStringOption(addTierChoices) .addStringOption(addUsernameChoices), diff --git a/src/commands/permissions.ts b/src/commands/permissions.ts index ab5052cf1..9afd85be9 100644 --- a/src/commands/permissions.ts +++ b/src/commands/permissions.ts @@ -4,9 +4,6 @@ import { CommandRegistry } from '../events/interactionCreate'; export const permissionsCommand = new Promise((resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('permissions'), async handler(interaction) { diff --git a/src/commands/ping.ts b/src/commands/ping.ts index 6aedff6e2..1823f3a33 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -4,8 +4,6 @@ import { CommandRegistry } from '../events/interactionCreate'; export const pingCommand = new Promise((resolve) => { resolve({ - inProduction: true, - inPublic: true, handlesInteraction: true, command: createLocalizedCommand('ping', [ diff --git a/src/commands/playerAchievements.ts b/src/commands/playerAchievements.ts deleted file mode 100644 index 1f029216f..000000000 --- a/src/commands/playerAchievements.ts +++ /dev/null @@ -1,80 +0,0 @@ -// _____ _____ _ _ _ _ _____ ____ __ __ ______ ____ _____ _ __ -// |_ _| / ____| | | | /\ | | | | / ____/ __ \| \/ | ____| | _ \ /\ / ____| |/ / -// | | | (___ | |__| | / \ | | | | | | | | | | \ / | |__ | |_) | / \ | | | ' / -// | | \___ \| __ | / /\ \ | | | | | | | | | | |\/| | __| | _ < / /\ \| | | < -// _| |_ ____) | | | |/ ____ \| |____| |____ | |___| |__| | | | | |____ | |_) / ____ \ |____| . \ -// |_____| |_____/|_| |_/_/ \_\______|______| \_____\____/|_| |_|______| |____/_/ \_\_____|_|\_\ - -// import { SlashCommandBuilder } from 'discord.js'; -// import { startCase } from 'lodash'; -// import markdownEscape from 'markdown-escape'; -// import { getAccountAchievements } from '../core/blitz/getAccountAchievements'; -// import { getAccountInfo } from '../core/blitz/getAccountInfo'; -// import addUsernameChoices from '../core/discord/addUsernameChoices'; -// import autocompleteUsername from '../core/discord/autocompleteUsername'; -// import embedInfo from '../core/discord/embedInfo'; -// import markdownTable, { TableInputEntry } from '../core/discord/markdownTable'; -// import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand'; -// import { CommandRegistry } from '../events/interactionCreate'; - -// type SortBy = 'name' | 'count'; - -// export const playerAchievementsCommand = new Promise( -// (resolve) => { -// resolve({ -// inProduction: true, -// inPublic: true, - -// command: new SlashCommandBuilder() -// .setName('player-achievements') -// .setDescription("All the player's achievements") -// .addStringOption(addUsernameChoices) -// .addStringOption((option) => -// option -// .setName('sort') -// .setDescription('What to sort by (default: name)') -// .addChoices( -// { name: 'By name', value: 'name' satisfies SortBy }, -// { name: 'By count', value: 'count' satisfies SortBy }, -// ), -// ), - -// async handler(interaction) { -// const sortBy = (interaction.options.getString('sort') ?? -// 'name') as SortBy; -// const account = await resolvePlayerFromCommand(interaction); -// const { id, region: region } = account; -// const accountInfo = await getAccountInfo(region, id); -// const accountsAchievements = await getAccountAchievements(region, id); -// const accountAchievements = accountsAchievements; -// const compound = { -// ...accountAchievements.achievements, -// ...accountAchievements.max_series, -// }; - -// return embedInfo( -// `${markdownEscape(accountInfo.nickname)}'s information`, - -// markdownTable( -// Object.keys(compound) -// .filter((achievement) => compound[achievement] > 0) -// .sort( -// sortBy === 'count' -// ? (a, b) => compound[b] - compound[a] -// : undefined, -// ) -// .map( -// (achievement) => -// [ -// startCase(achievement), -// compound[achievement], -// ] as TableInputEntry, -// ), -// ), -// ); -// }, - -// autocomplete: autocompleteUsername, -// }); -// }, -// ); diff --git a/src/commands/playerInfo.ts b/src/commands/playerInfo.ts index cbb6b2cb4..f6af4a6dc 100644 --- a/src/commands/playerInfo.ts +++ b/src/commands/playerInfo.ts @@ -11,9 +11,6 @@ import { CommandRegistry } from '../events/interactionCreate'; export const playerInfoCommand = new Promise((resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('player-info').addStringOption(addUsernameChoices), diff --git a/src/commands/rating.tsx b/src/commands/rating.tsx index 885baa713..fc62d2465 100644 --- a/src/commands/rating.tsx +++ b/src/commands/rating.tsx @@ -47,9 +47,6 @@ export const ratingCommand = new Promise((resolve) => { }, ]), - inProduction: true, - inPublic: true, - async handler(interaction) { const subcommand = interaction.options.getSubcommand(true) as | 'season' diff --git a/src/commands/ratingLeaderboard.tsx b/src/commands/ratingLeaderboard.tsx index 3c694d24b..50f75f4eb 100644 --- a/src/commands/ratingLeaderboard.tsx +++ b/src/commands/ratingLeaderboard.tsx @@ -213,9 +213,6 @@ export const ratingLeaderboardCommand = new Promise( } resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('rating-leaderboard', [ { subcommand: 'neighbors', diff --git a/src/commands/replay.tsx b/src/commands/replay.tsx index eebe918df..9adc9fc31 100644 --- a/src/commands/replay.tsx +++ b/src/commands/replay.tsx @@ -453,8 +453,6 @@ function Header() { export const replayCommand = new Promise((resolve) => { resolve({ - inProduction: true, - inPublic: true, command: createLocalizedCommand('replay').addAttachmentOption((option) => option.setName('file').setDescription('Replay file').setRequired(true), ), diff --git a/src/commands/research.tsx b/src/commands/research.tsx index 42f695a59..0b1a91f9e 100644 --- a/src/commands/research.tsx +++ b/src/commands/research.tsx @@ -30,9 +30,6 @@ export const researchCommand = new Promise((resolve) => { const { t } = translator(Locale.EnglishUS); resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('research') .addStringOption((option) => option diff --git a/src/commands/searchClans.ts b/src/commands/searchClans.ts index 2307ad249..fd9f1141e 100644 --- a/src/commands/searchClans.ts +++ b/src/commands/searchClans.ts @@ -15,9 +15,6 @@ const DEFAULT_LIMIT = 25; export const searchClansCommand = new Promise((resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('search-clans') .addStringOption(addRegionChoices) .addStringOption((option) => diff --git a/src/commands/searchPlayers.ts b/src/commands/searchPlayers.ts index 5be8c4f5b..ef82a3413 100644 --- a/src/commands/searchPlayers.ts +++ b/src/commands/searchPlayers.ts @@ -18,9 +18,6 @@ export const searchPlayersCommand = new Promise((resolve) => { const { t, translate } = translator(Locale.EnglishUS); resolve({ - inProduction: true, - inPublic: true, - command: createLocalizedCommand('search-players') .addStringOption(addRegionChoices) .addStringOption((option) => diff --git a/src/commands/searchTanks.ts b/src/commands/searchTanks.ts deleted file mode 100644 index e7a25f7c3..000000000 --- a/src/commands/searchTanks.ts +++ /dev/null @@ -1,51 +0,0 @@ -// _____ _____ _ _ _ _ _____ ____ __ __ ______ ____ _____ _ __ -// |_ _| / ____| | | | /\ | | | | / ____/ __ \| \/ | ____| | _ \ /\ / ____| |/ / -// | | | (___ | |__| | / \ | | | | | | | | | | \ / | |__ | |_) | / \ | | | ' / -// | | \___ \| __ | / /\ \ | | | | | | | | | | |\/| | __| | _ < / /\ \| | | < -// _| |_ ____) | | | |/ ____ \| |____| |____ | |___| |__| | | | | |____ | |_) / ____ \ |____| . \ -// |_____| |_____/|_| |_/_/ \_\______|______| \_____\____/|_| |_|______| |____/_/ \_\_____|_|\_\ - -// import { SlashCommandBuilder } from 'discord.js'; -// import { go } from 'fuzzysort'; -// import markdownEscape from 'markdown-escape'; -// import { tankNames } from '../core/blitzkit/tankDefinitions'; -// import addTankChoices from '../core/discord/addTankChoices'; -// import embedInfo from '../core/discord/embedInfo'; -// import { CommandRegistry } from '../events/interactionCreate'; - -// export const searchTanksCommand = new Promise((resolve) => { -// resolve({ -// inProduction: true, -// inPublic: true, - -// command: new SlashCommandBuilder() -// .setName('search-tanks') -// .setDescription('Search tanks') -// .addStringOption((option) => -// addTankChoices(option).setAutocomplete(false), -// ) -// .addIntegerOption((option) => -// option -// .setName('limit') -// .setDescription('The size of the search result (default: 25)') -// .setMinValue(1) -// .setMaxValue(100), -// ), - -// async handler(interaction) { -// const tank = interaction.options.getString('tank')!; -// const limit = interaction.options.getInteger('limit') ?? 25; -// const results = go(tank, await tankNames, { -// limit, -// keys: ['combined'], -// }).map((result) => result.obj.original); - -// return embedInfo( -// `Tank search for "${markdownEscape(tank)}"`, -// results.length === 0 -// ? 'No tanks found.' -// : `\`\`\`\n${results.join('\n')}\n\`\`\``, -// ); -// }, -// }); -// }); diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index 1fd8e31ae..6ea70d8e4 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -71,9 +71,6 @@ async function render( export const statsCommand = new Promise(async (resolve) => { resolve({ - inProduction: true, - inPublic: true, - command: await addPeriodicFilterOptions( createLocalizedCommand('stats'), (option) => option.addStringOption(addUsernameChoices), diff --git a/src/commands/today.ts b/src/commands/today.ts index 383919bbf..c4d97482e 100644 --- a/src/commands/today.ts +++ b/src/commands/today.ts @@ -21,9 +21,6 @@ export const todayCommand = new Promise(async (resolve) => { const awaitedGameDefinitions = await gameDefinitions; resolve({ - inProduction: true, - inPublic: true, - command: addFilterOptions( createLocalizedCommand('today'), awaitedGameDefinitions.nations, diff --git a/src/core/discord/client.ts b/src/core/discord/client.ts index 3b9e6bbd8..c911a2408 100644 --- a/src/core/discord/client.ts +++ b/src/core/discord/client.ts @@ -1,5 +1,4 @@ import { Client, GatewayIntentBits } from 'discord.js'; -import guildMemberAdd from '../../events/guildMemberAdd'; import interactionCreate from '../../events/interactionCreate'; import ready from '../../events/ready'; @@ -7,5 +6,4 @@ export const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers], }) .on('ready', ready) - .on('guildMemberAdd', guildMemberAdd) .on('interactionCreate', interactionCreate); diff --git a/src/events/guildMemberAdd.ts b/src/events/guildMemberAdd.ts deleted file mode 100644 index 0f837d9ce..000000000 --- a/src/events/guildMemberAdd.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { AttachmentBuilder, GuildMember, TextChannel } from 'discord.js'; -import discord from '../../discord.json' assert { type: 'json' }; - -export default async function guildMemberAdd(member: GuildMember) { - if (member.guild.id === discord.sklld_guild_id) { - await ( - member.guild.channels.cache.get( - discord.sklld_verify_channel, - ) as TextChannel - ).send({ - content: `# Welcome, ${member.toString()}!\nPlease use the \`/link\` command like the video below to continue.`, - files: [new AttachmentBuilder('https://i.imgur.com/2p6GFgC.gif')], - }); - } -} diff --git a/src/events/interactionCreate/handlers/chatInputCommand.ts b/src/events/interactionCreate/handlers/chatInputCommand.ts index 2e1fffa43..807861844 100644 --- a/src/events/interactionCreate/handlers/chatInputCommand.ts +++ b/src/events/interactionCreate/handlers/chatInputCommand.ts @@ -16,11 +16,6 @@ import { translator } from '../../../core/localization/translator'; import { UserError } from '../../../hooks/userError'; import { Writeable } from '../../../types/writable'; -const previewServers = [ - '734786591205359697', // abhi - '460165161156870161', // optml -]; - export default async function handleChatInputCommand( interaction: ChatInputCommandInteraction, ) { @@ -30,16 +25,6 @@ export default async function handleChatInputCommand( await interaction.deferReply(); try { - if ( - registry.inPreview && - !previewServers.includes(`${interaction.guildId}`) - ) { - const { t } = translator(interaction.locale); - interaction.editReply(t`bot.common.errors.preview`); - - return; - } - const returnable = await registry.handler(interaction); if (registry.handlesInteraction) return; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 64b179583..bf591d55a 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -8,13 +8,11 @@ import { EmbedBuilder, Interaction, REST, - RESTPostAPIChatInputApplicationCommandsJSONBody, Routes, SlashCommandBuilder, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandsOnlyBuilder, } from 'discord.js'; -import discord from '../../../discord.json' assert { type: 'json' }; import { aboutCommand } from '../../commands/about'; import { breakdownCommand } from '../../commands/breakdown'; import { debugCommand } from '../../commands/debug'; @@ -58,10 +56,6 @@ export type InteractionReturnable = | Promise; interface CommandRegistryBase { - inProduction: boolean; - inPublic: boolean; - inPreview?: boolean; - command: | SlashCommandBuilder | SlashCommandSubcommandsOnlyBuilder @@ -124,38 +118,13 @@ export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => { }); const rest = new REST().setToken(secrets.DISCORD_TOKEN); -export const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = - []; -export const publicCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = - []; commands.then((awaitedCommands) => { - Object.values(awaitedCommands).forEach((registry) => { - const json = registry.command.toJSON(); + const body = Object.values(awaitedCommands).map((registry) => + registry.command.toJSON(), + ); - if (registry.inPublic) { - publicCommands.push(json); - } else { - guildCommands.push(json); - } - }); - - try { - rest.put(Routes.applicationCommands(getClientId()), { - body: publicCommands, - }); - - (isDev() - ? [discord.test_guild_id] - : [discord.tres_guild_id, discord.sklld_guild_id] - ).forEach((guildId) => - rest.put(Routes.applicationGuildCommands(getClientId(), guildId), { - body: guildCommands, - }), - ); - } catch (error) { - console.error(error); - } + rest.put(Routes.applicationCommands(getClientId()), { body }); }); export default async function interactionCreate(