mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: remove legacy bot code
This commit is contained in:
1 parent
9ffd20ffbf
commit
3f83fffade
28 files changed
+5
-589
No files matched your search
@@ -21,9 +21,6 @@ const DOCS: Record<Subcommand, string> = {
|
||||
|
||||
export const aboutCommand = new Promise<CommandRegistry>(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<CommandRegistry>(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) <
|
||||
|
||||
@@ -19,9 +19,6 @@ import { renderBreakdown } from './render';
|
||||
export const breakdownCommand = new Promise<CommandRegistry>(
|
||||
async (resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: await addPeriodicFilterOptions(
|
||||
createLocalizedCommand('breakdown'),
|
||||
(option) => option.addStringOption(addUsernameChoices),
|
||||
|
||||
@@ -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<PlayerHistoriesRaw>)
|
||||
// .then((data) => ({
|
||||
// id,
|
||||
// jointVictory: data[0]?.achievements.jointVictoryCount as
|
||||
// | number
|
||||
// | undefined,
|
||||
// })),
|
||||
// ),
|
||||
// ).then((data) =>
|
||||
// data.reduce<Record<number, number | undefined>>(
|
||||
// (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,
|
||||
// };
|
||||
@@ -8,9 +8,6 @@ const executionStart = new Date().getTime();
|
||||
|
||||
export const debugCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('debug'),
|
||||
|
||||
async handler(interaction) {
|
||||
|
||||
@@ -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<SkilledClan, string> = {
|
||||
// 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<PossiblyPromise<number>>(
|
||||
// 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<PossiblyPromise<number>>(
|
||||
// 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<PossiblyPromise<number>>(
|
||||
// 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<PossiblyPromise<number>>(
|
||||
// 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<PossiblyPromise<number>>(
|
||||
// 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);
|
||||
// },
|
||||
// };
|
||||
@@ -110,9 +110,6 @@ async function render(
|
||||
export const evolutionCommand = new Promise<CommandRegistry>(
|
||||
async (resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('evolution', [
|
||||
{
|
||||
group: 'player',
|
||||
|
||||
@@ -81,9 +81,6 @@ async function render(
|
||||
export const fullStatsCommand = new Promise<CommandRegistry>(
|
||||
async (resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: await addPeriodicFilterOptions(
|
||||
createLocalizedCommand('full-stats'),
|
||||
(option) => option.addStringOption(addUsernameChoices),
|
||||
|
||||
@@ -17,9 +17,6 @@ const DEFAULT_THRESHOLD = 7;
|
||||
|
||||
export const inactiveCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('inactive')
|
||||
.addStringOption(addClanChoices)
|
||||
.addNumberOption((option) => {
|
||||
|
||||
@@ -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<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('link').addStringOption((option) =>
|
||||
addUsernameChoices(option).setRequired(true),
|
||||
),
|
||||
@@ -35,28 +28,6 @@ export const verifyCommand = new Promise<CommandRegistry>((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 [
|
||||
<CommandWrapper fat>
|
||||
<div
|
||||
|
||||
@@ -23,9 +23,6 @@ const TANKS_PER_MESSAGE = 64;
|
||||
|
||||
export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('owned-tanks')
|
||||
.addStringOption(addTierChoices)
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
@@ -4,9 +4,6 @@ import { CommandRegistry } from '../events/interactionCreate';
|
||||
|
||||
export const permissionsCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('permissions'),
|
||||
|
||||
async handler(interaction) {
|
||||
|
||||
@@ -4,8 +4,6 @@ import { CommandRegistry } from '../events/interactionCreate';
|
||||
|
||||
export const pingCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
handlesInteraction: true,
|
||||
|
||||
command: createLocalizedCommand('ping', [
|
||||
|
||||
@@ -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<CommandRegistry>(
|
||||
// (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,
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
@@ -11,9 +11,6 @@ import { CommandRegistry } from '../events/interactionCreate';
|
||||
|
||||
export const playerInfoCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command:
|
||||
createLocalizedCommand('player-info').addStringOption(addUsernameChoices),
|
||||
|
||||
|
||||
@@ -47,9 +47,6 @@ export const ratingCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
},
|
||||
]),
|
||||
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
async handler(interaction) {
|
||||
const subcommand = interaction.options.getSubcommand(true) as
|
||||
| 'season'
|
||||
|
||||
@@ -213,9 +213,6 @@ export const ratingLeaderboardCommand = new Promise<CommandRegistry>(
|
||||
}
|
||||
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('rating-leaderboard', [
|
||||
{
|
||||
subcommand: 'neighbors',
|
||||
|
||||
@@ -453,8 +453,6 @@ function Header() {
|
||||
|
||||
export const replayCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
command: createLocalizedCommand('replay').addAttachmentOption((option) =>
|
||||
option.setName('file').setDescription('Replay file').setRequired(true),
|
||||
),
|
||||
|
||||
@@ -30,9 +30,6 @@ export const researchCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
const { t } = translator(Locale.EnglishUS);
|
||||
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('research')
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
|
||||
@@ -15,9 +15,6 @@ const DEFAULT_LIMIT = 25;
|
||||
|
||||
export const searchClansCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('search-clans')
|
||||
.addStringOption(addRegionChoices)
|
||||
.addStringOption((option) =>
|
||||
|
||||
@@ -18,9 +18,6 @@ export const searchPlayersCommand = new Promise<CommandRegistry>((resolve) => {
|
||||
const { t, translate } = translator(Locale.EnglishUS);
|
||||
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: createLocalizedCommand('search-players')
|
||||
.addStringOption(addRegionChoices)
|
||||
.addStringOption((option) =>
|
||||
|
||||
@@ -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<CommandRegistry>((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\`\`\``,
|
||||
// );
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
@@ -71,9 +71,6 @@ async function render(
|
||||
|
||||
export const statsCommand = new Promise<CommandRegistry>(async (resolve) => {
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: await addPeriodicFilterOptions(
|
||||
createLocalizedCommand('stats'),
|
||||
(option) => option.addStringOption(addUsernameChoices),
|
||||
|
||||
@@ -21,9 +21,6 @@ export const todayCommand = new Promise<CommandRegistry>(async (resolve) => {
|
||||
const awaitedGameDefinitions = await gameDefinitions;
|
||||
|
||||
resolve({
|
||||
inProduction: true,
|
||||
inPublic: true,
|
||||
|
||||
command: addFilterOptions(
|
||||
createLocalizedCommand('today'),
|
||||
awaitedGameDefinitions.nations,
|
||||
|
||||
@@ -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);
|
||||
@@ -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')],
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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<CacheType>,
|
||||
) {
|
||||
@@ -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;
|
||||
|
||||
@@ -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<InteractionIterableReturnable>;
|
||||
|
||||
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(
|
||||
|
||||
Reference in new issue
Block a user