mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: cleaned discord
This commit is contained in:
1 parent
169588a211
commit
01ed20941d
30 files changed
+93
-121
No files matched your search
@@ -3,8 +3,8 @@ import packageJSON from '../../package.json' assert { type: 'json' };
|
||||
import { client } from '../bot.js';
|
||||
import { tankopedia } from '../core/blitz/tankopedia.js';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages.js';
|
||||
import cleanTable from '../core/discord/cleanTable.js';
|
||||
import infoEmbed from '../core/discord/infoEmbed.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import markdownTable from '../core/discord/markdownTable.js';
|
||||
import getClientId from '../core/node/getClientId.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
|
||||
@@ -23,9 +23,9 @@ export default {
|
||||
const currentTime = new Date().getTime();
|
||||
const uptime = currentTime - executionStart;
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`${client.user?.username} debug information`,
|
||||
cleanTable([
|
||||
markdownTable([
|
||||
['Version', packageJSON.version],
|
||||
['Client ID', getClientId()],
|
||||
['Tag', interaction.client.user.tag],
|
||||
|
||||
@@ -7,10 +7,10 @@ import getPeriodNow from '../core/blitzstars/getPeriodNow.js';
|
||||
import getPeriodStart from '../core/blitzstars/getPeriodStart.js';
|
||||
import getTankStatsDiffed from '../core/blitzstars/getTankStatsDiffed.js';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages.js';
|
||||
import addUsernameOption from '../core/discord/addUsernameOption.js';
|
||||
import cleanTable, { TableInput } from '../core/discord/cleanTable.js';
|
||||
import negativeEmbed from '../core/discord/negativeEmbed.js';
|
||||
import positiveEmbed from '../core/discord/positiveEmbed.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import embedNegative from '../core/discord/embedNegative.js';
|
||||
import embedPositive from '../core/discord/embedPositive.js';
|
||||
import markdownTable, { TableInput } from '../core/discord/markdownTable.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
@@ -44,7 +44,7 @@ export default {
|
||||
)
|
||||
.setRequired(true),
|
||||
)
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
async handler(interaction) {
|
||||
const clan = interaction.options.getString('clan') as SkilledClan;
|
||||
@@ -137,7 +137,7 @@ export default {
|
||||
isEligible = problems.length === 0;
|
||||
body = isEligible
|
||||
? 'Player is fully eligible.'
|
||||
: `Player is not eligible. Shortcomings in 30-day statistics:\n\n${cleanTable(
|
||||
: `Player is not eligible. Shortcomings in 30-day statistics:\n\n${markdownTable(
|
||||
problems,
|
||||
)}`;
|
||||
} else if (clan === 'SMRI') {
|
||||
@@ -162,11 +162,11 @@ export default {
|
||||
isEligible = problems.length === 0;
|
||||
body = isEligible
|
||||
? 'Player is fully eligible.'
|
||||
: `Player is not eligible. Shortcomings in career statistics:\n\n${cleanTable(
|
||||
: `Player is not eligible. Shortcomings in career statistics:\n\n${markdownTable(
|
||||
problems,
|
||||
)}`;
|
||||
}
|
||||
|
||||
return (isEligible ? positiveEmbed : negativeEmbed)(title, body);
|
||||
return (isEligible ? embedPositive : embedNegative)(title, body);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import resolveTankId from '../core/blitz/resolveTankId.js';
|
||||
import addStatsSubCommandGroups from '../core/discord/addStatsSubCommandGroups.js';
|
||||
import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups.js';
|
||||
import autocompleteTanks from '../core/discord/autocompleteTanks.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import tanksAutocomplete from '../core/discord/tanksAutocomplete.js';
|
||||
import usernameAutocomplete from '../core/discord/usernameAutocomplete.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import evolution from '../renderers/evolution.js';
|
||||
import { StatType } from '../renderers/stats.js';
|
||||
@@ -14,7 +14,7 @@ export default {
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: addStatsSubCommandGroups(
|
||||
command: addStatTypeSubCommandGroups(
|
||||
new SlashCommandBuilder()
|
||||
.setName('evolution')
|
||||
.setDescription('Evolution of statistics'),
|
||||
@@ -45,7 +45,7 @@ export default {
|
||||
},
|
||||
|
||||
autocomplete: (interaction) => {
|
||||
usernameAutocomplete(interaction);
|
||||
tanksAutocomplete(interaction);
|
||||
autocompleteUsername(interaction);
|
||||
autocompleteTanks(interaction);
|
||||
},
|
||||
} satisfies CommandRegistry;
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import { client } from '../bot.js';
|
||||
import infoEmbed from '../core/discord/infoEmbed.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import {
|
||||
CommandRegistry,
|
||||
guildCommands,
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
.setDescription('All the help you need about the bot'),
|
||||
|
||||
handler(interaction) {
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`${client.user?.username} help`,
|
||||
`**About**\n${
|
||||
client.user?.username
|
||||
|
||||
@@ -8,7 +8,7 @@ import { BLITZ_SERVERS } from '../constants/servers.js';
|
||||
import getBlitzClan from '../core/blitz/getBlitzClan.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import addClanChoices from '../core/discord/addClanChoices.js';
|
||||
import clanAutocomplete from '../core/discord/clanAutocomplete.js';
|
||||
import autocompleteClan from '../core/discord/autocompleteClan.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
@@ -84,5 +84,5 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
autocomplete: clanAutocomplete,
|
||||
autocomplete: autocompleteClan,
|
||||
} satisfies CommandRegistry;
|
||||
@@ -12,9 +12,9 @@ import {
|
||||
Tier,
|
||||
tankopedia,
|
||||
} from '../core/blitz/tankopedia.js';
|
||||
import addUsernameOption from '../core/discord/addUsernameOption.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import usernameAutocomplete from '../core/discord/usernameAutocomplete.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
@@ -67,7 +67,7 @@ export default {
|
||||
)
|
||||
.setRequired(true),
|
||||
)
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
async handler(interaction) {
|
||||
const tier = Number(interaction.options.getString('tier'));
|
||||
@@ -120,5 +120,5 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
autocomplete: autocompleteUsername,
|
||||
} satisfies CommandRegistry;
|
||||
@@ -2,11 +2,13 @@ import { SlashCommandBuilder } from 'discord.js';
|
||||
import { startCase } from 'lodash';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import addUsernameOption from '../core/discord/addUsernameOption.js';
|
||||
import cleanTable, { TableInputEntry } from '../core/discord/cleanTable.js';
|
||||
import infoEmbed from '../core/discord/infoEmbed.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import markdownTable, {
|
||||
TableInputEntry,
|
||||
} from '../core/discord/markdownTable.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import usernameAutocomplete from '../core/discord/usernameAutocomplete.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountAchievements } from '../types/accountAchievements.js';
|
||||
@@ -22,7 +24,7 @@ export default {
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('playerachievements')
|
||||
.setDescription("All the player's achievements")
|
||||
.addStringOption(addUsernameOption)
|
||||
.addStringOption(addUsernameChoices)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName('sort')
|
||||
@@ -50,10 +52,10 @@ export default {
|
||||
...accountAchievements.max_series,
|
||||
};
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`${markdownEscape(accounts[id].nickname)}'s information`,
|
||||
|
||||
cleanTable(
|
||||
markdownTable(
|
||||
Object.keys(compound)
|
||||
.filter((achievement) => compound[achievement] > 0)
|
||||
.sort(
|
||||
@@ -72,5 +74,5 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
autocomplete: autocompleteUsername,
|
||||
} satisfies CommandRegistry;
|
||||
@@ -1,11 +1,11 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import addUsernameOption from '../core/discord/addUsernameOption.js';
|
||||
import cleanTable from '../core/discord/cleanTable.js';
|
||||
import infoEmbed from '../core/discord/infoEmbed.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import markdownTable from '../core/discord/markdownTable.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import usernameAutocomplete from '../core/discord/usernameAutocomplete.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('playerinfo')
|
||||
.setDescription('Basic information about a player')
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
async handler(interaction) {
|
||||
const account = await resolvePlayerFromCommand(interaction);
|
||||
@@ -28,10 +28,10 @@ export default {
|
||||
);
|
||||
const accountInfo = accounts[id];
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`${markdownEscape(accountInfo.nickname)}'s information`,
|
||||
|
||||
cleanTable([
|
||||
markdownTable([
|
||||
['Nickname', `${accountInfo.nickname}`],
|
||||
['Battles', `${accountInfo.statistics.all.battles}`],
|
||||
[
|
||||
@@ -56,5 +56,5 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
autocomplete: autocompleteUsername,
|
||||
} satisfies CommandRegistry;
|
||||
@@ -4,7 +4,7 @@ import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import addClanChoices from '../core/discord/addClanChoices.js';
|
||||
import addServerChoices from '../core/discord/addServerChoices.js';
|
||||
import infoEmbed from '../core/discord/infoEmbed.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { ClanList } from '../types/clanList.js';
|
||||
@@ -35,7 +35,7 @@ export default {
|
||||
`https://api.wotblitz.${server}/wotb/clans/list/?application_id=${WARGAMING_APPLICATION_ID}&search=${clan}&limit=${limit}`,
|
||||
);
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`Clan search for "${markdownEscape(clan)}" in ${BLITZ_SERVERS[server]}`,
|
||||
clanList.length === 0
|
||||
? 'No clans found.'
|
||||
|
||||
@@ -4,8 +4,8 @@ import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import { usernamePattern } from '../core/blitz/listPlayers.js';
|
||||
import addServerChoices from '../core/discord/addServerChoices.js';
|
||||
import addUsernameOption from '../core/discord/addUsernameOption.js';
|
||||
import infoEmbed from '../core/discord/infoEmbed.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountList } from '../types/accountList.js';
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
.setDescription('Search players in a Blitz server')
|
||||
.addStringOption(addServerChoices)
|
||||
.addStringOption((option) =>
|
||||
addUsernameOption(option).setAutocomplete(false).setRequired(true),
|
||||
addUsernameChoices(option).setAutocomplete(false).setRequired(true),
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
@@ -43,7 +43,7 @@ export default {
|
||||
)
|
||||
: [];
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`Player search for "${markdownEscape(name)}" in ${BLITZ_SERVERS[server]}`,
|
||||
`\`\`\`${
|
||||
players.length === 0
|
||||
|
||||
@@ -3,7 +3,7 @@ import { go } from 'fuzzysort';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { TANK_NAMES } from '../core/blitz/tankopedia.js';
|
||||
import addTankChoices from '../core/discord/addTankChoices.js';
|
||||
import infoEmbed from '../core/discord/infoEmbed.js';
|
||||
import embedInfo from '../core/discord/embedInfo.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
|
||||
export default {
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
(result) => result.target,
|
||||
);
|
||||
|
||||
return infoEmbed(
|
||||
return embedInfo(
|
||||
`Tank search for "${markdownEscape(tank)}"`,
|
||||
results.length === 0
|
||||
? 'No tanks found.'
|
||||
|
||||
@@ -2,7 +2,9 @@ import { SlashCommandBuilder } from 'discord.js';
|
||||
import { CYCLIC_API } from '../constants/cyclic.js';
|
||||
import resolveTankId from '../core/blitz/resolveTankId.js';
|
||||
import { Period } from '../core/discord/addPeriodSubCommands.js';
|
||||
import addStatsSubCommandGroups from '../core/discord/addStatsSubCommandGroups.js';
|
||||
import addStatTypeSubCommandGroups from '../core/discord/addStatTypeSubCommandGroups.js';
|
||||
import autocompleteTanks from '../core/discord/autocompleteTanks.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import interactionToURL from '../core/discord/interactionToURL.js';
|
||||
import linkButton from '../core/discord/linkButton.js';
|
||||
import primaryButton from '../core/discord/primaryButton.js';
|
||||
@@ -10,8 +12,6 @@ import resolvePeriodFromButton from '../core/discord/resolvePeriodFromButton.js'
|
||||
import resolvePeriodFromCommand from '../core/discord/resolvePeriodFromCommand.js';
|
||||
import resolvePlayerFromButton from '../core/discord/resolvePlayerFromButton.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import tanksAutocomplete from '../core/discord/tanksAutocomplete.js';
|
||||
import usernameAutocomplete from '../core/discord/usernameAutocomplete.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import stats, { StatType } from '../renderers/stats.js';
|
||||
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
inDevelopment: false,
|
||||
inPublic: true,
|
||||
|
||||
command: addStatsSubCommandGroups(
|
||||
command: addStatTypeSubCommandGroups(
|
||||
new SlashCommandBuilder()
|
||||
.setName('stats')
|
||||
.setDescription('In-game statistics'),
|
||||
@@ -51,8 +51,8 @@ export default {
|
||||
},
|
||||
|
||||
autocomplete: (interaction) => {
|
||||
usernameAutocomplete(interaction);
|
||||
tanksAutocomplete(interaction);
|
||||
autocompleteUsername(interaction);
|
||||
autocompleteTanks(interaction);
|
||||
},
|
||||
|
||||
async button(interaction) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import addUsernameOption from '../core/discord/addUsernameOption.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import usernameAutocomplete from '../core/discord/usernameAutocomplete.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import today from '../renderers/today.js';
|
||||
|
||||
@@ -13,7 +13,7 @@ export default {
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('today')
|
||||
.setDescription('A general daily breakdown of your performance')
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
|
||||
async handler(interaction) {
|
||||
const player = await resolvePlayerFromCommand(interaction);
|
||||
@@ -21,5 +21,5 @@ export default {
|
||||
return await today(player);
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
autocomplete: autocompleteUsername,
|
||||
} satisfies CommandRegistry;
|
||||
+11
-11
@@ -2,11 +2,11 @@ import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import addUsernameOption from '../core/discord/addUsernameOption.js';
|
||||
import negativeEmbed from '../core/discord/negativeEmbed.js';
|
||||
import positiveEmbed from '../core/discord/positiveEmbed.js';
|
||||
import addUsernameChoices from '../core/discord/addUsernameChoices.js';
|
||||
import autocompleteUsername from '../core/discord/autocompleteUsername.js';
|
||||
import embedNegative from '../core/discord/embedNegative.js';
|
||||
import embedPositive from '../core/discord/embedPositive.js';
|
||||
import resolvePlayerFromCommand from '../core/discord/resolvePlayerFromCommand.js';
|
||||
import usernameAutocomplete from '../core/discord/usernameAutocomplete.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('verify')
|
||||
.setDescription("Set's the user's username to their in-game name")
|
||||
.addStringOption((option) => addUsernameOption(option).setRequired(true)),
|
||||
.addStringOption((option) => addUsernameChoices(option).setRequired(true)),
|
||||
|
||||
async handler(interaction) {
|
||||
const blitzAccount = await resolvePlayerFromCommand(interaction);
|
||||
@@ -38,13 +38,13 @@ export default {
|
||||
interaction.guild?.members.cache.get(interaction.member?.user.id);
|
||||
|
||||
if (!interaction.guild?.members.me?.permissions.has('ManageNicknames')) {
|
||||
return negativeEmbed(
|
||||
return embedNegative(
|
||||
`${markdownEscape(interaction.user.username)} failed to verify`,
|
||||
"I don't have the permission to change your nickname.",
|
||||
);
|
||||
}
|
||||
if (!interaction.member || !member) {
|
||||
return negativeEmbed(
|
||||
return embedNegative(
|
||||
`${interaction.user.username} is not in this server`,
|
||||
"I couldn't find this person in this server. Did they leave?",
|
||||
);
|
||||
@@ -55,7 +55,7 @@ export default {
|
||||
|
||||
if (interaction.guildId === discord.sklld_guild_id) {
|
||||
if (!interaction.guild?.members.me?.permissions.has('ManageRoles')) {
|
||||
return negativeEmbed(
|
||||
return embedNegative(
|
||||
`${markdownEscape(interaction.user.username)} failed to verify`,
|
||||
"I don't have the permission to change your manage roles.",
|
||||
);
|
||||
@@ -65,19 +65,19 @@ export default {
|
||||
await member.roles.add(discord.sklld_peasant_role);
|
||||
}
|
||||
|
||||
return positiveEmbed(
|
||||
return embedPositive(
|
||||
`${interaction.user.username} is verified`,
|
||||
`The user is now verified as ${markdownEscape(
|
||||
accountInfo[id].nickname,
|
||||
)}${markdownEscape(clanTag)}`,
|
||||
);
|
||||
} catch (error) {
|
||||
return negativeEmbed(
|
||||
return embedNegative(
|
||||
`${interaction.user.username} failed to verify`,
|
||||
"I can't change your nickname because you have higher permissions than me. Try setting your nickname to your Blitz username manually.",
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
autocomplete: usernameAutocomplete,
|
||||
autocomplete: autocompleteUsername,
|
||||
} satisfies CommandRegistry;
|
||||
+6
-4
@@ -1,13 +1,15 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import addPeriodSubCommands from './addPeriodSubCommands.js';
|
||||
import addTankChoices from './addTankChoices.js';
|
||||
import addUsernameOption from './addUsernameOption.js';
|
||||
import addUsernameChoices from './addUsernameChoices.js';
|
||||
|
||||
export default function addStatsSubCommandGroups(option: SlashCommandBuilder) {
|
||||
export default function addStatTypeSubCommandGroups(
|
||||
option: SlashCommandBuilder,
|
||||
) {
|
||||
return option
|
||||
.addSubcommandGroup((option) =>
|
||||
addPeriodSubCommands(option, (option) =>
|
||||
option.addStringOption(addUsernameOption),
|
||||
option.addStringOption(addUsernameChoices),
|
||||
)
|
||||
.setName('player')
|
||||
.setDescription("Player's statistics"),
|
||||
@@ -16,7 +18,7 @@ export default function addStatsSubCommandGroups(option: SlashCommandBuilder) {
|
||||
addPeriodSubCommands(option, (option) =>
|
||||
option
|
||||
.addStringOption(addTankChoices)
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption(addUsernameChoices),
|
||||
)
|
||||
.setName('tank')
|
||||
.setDescription("Tank's statistics"),
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SlashCommandStringOption } from 'discord.js';
|
||||
|
||||
export default function addUsernameOption(option: SlashCommandStringOption) {
|
||||
export default function addUsernameChoices(option: SlashCommandStringOption) {
|
||||
return option
|
||||
.setName('username')
|
||||
.setDescription(
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
import { BLITZ_SERVERS } from '../../constants/servers.js';
|
||||
import listClans from '../blitz/listClans.js';
|
||||
|
||||
export default async function clanAutocomplete(
|
||||
export default async function autocompleteClan(
|
||||
interaction: AutocompleteInteraction<CacheType>,
|
||||
) {
|
||||
const focusedOption = interaction.options.getFocused(true);
|
||||
@@ -7,7 +7,7 @@ import { go } from 'fuzzysort';
|
||||
import resolveTankName from '../blitz/resolveTankName.js';
|
||||
import { TANKS } from '../blitz/tankopedia.js';
|
||||
|
||||
export default async function tanksAutocomplete(
|
||||
export default async function autocompleteTanks(
|
||||
interaction: AutocompleteInteraction<CacheType>,
|
||||
) {
|
||||
const focusedOption = interaction.options.getFocused(true);
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
import { BLITZ_SERVERS } from '../../constants/servers.js';
|
||||
import listPlayers from '../blitz/listPlayers.js';
|
||||
|
||||
export default async function usernameAutocomplete(
|
||||
export default async function autocompleteUsername(
|
||||
interaction: AutocompleteInteraction<CacheType>,
|
||||
) {
|
||||
const focusedOption = interaction.options.getFocused(true);
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { ACCENT_COLOR } from '../../constants/colors.js';
|
||||
|
||||
export default function infoEmbed(title: string, description: string) {
|
||||
export default function embedInfo(title: string, description: string) {
|
||||
return new EmbedBuilder()
|
||||
.setColor(ACCENT_COLOR)
|
||||
.setTitle(title)
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { NEGATIVE_COLOR } from '../../constants/colors.js';
|
||||
|
||||
export default function negativeEmbed(title: string, description: string) {
|
||||
export default function embedNegative(title: string, description: string) {
|
||||
return new EmbedBuilder()
|
||||
.setColor(NEGATIVE_COLOR)
|
||||
.setTitle(title)
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { POSITIVE_COLOR } from '../../constants/colors.js';
|
||||
|
||||
export default function positiveEmbed(title: string, description: string) {
|
||||
export default function embedPositive(title: string, description: string) {
|
||||
return new EmbedBuilder()
|
||||
.setColor(POSITIVE_COLOR)
|
||||
.setTitle(title)
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { WARNING_COLOR } from '../../constants/colors.js';
|
||||
|
||||
export default function warningEmbed(title: string, description: string) {
|
||||
export default function embedWarning(title: string, description: string) {
|
||||
return new EmbedBuilder()
|
||||
.setColor(WARNING_COLOR)
|
||||
.setTitle(title)
|
||||
@@ -1,12 +0,0 @@
|
||||
import { ButtonBuilder, ButtonStyle } from 'discord.js';
|
||||
import { BlitzServer } from '../../constants/servers.js';
|
||||
|
||||
export default function fullBlitzStarsStats(
|
||||
server: BlitzServer,
|
||||
username: string,
|
||||
) {
|
||||
return new ButtonBuilder()
|
||||
.setLabel('View on BlitzStars')
|
||||
.setURL(`https://www.blitzstars.com/player/${server}/${username}`)
|
||||
.setStyle(ButtonStyle.Link);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
|
||||
export default function generateCustomId(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
) {
|
||||
return `${interaction.commandName}/${
|
||||
interaction.options.getSubcommandGroup() ?? ''
|
||||
}/${interaction.options.getSubcommand() ?? ''}`;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
export type TableInputEntry = [string, string | number] | [];
|
||||
export type TableInput = TableInputEntry[];
|
||||
|
||||
export default function cleanTable(input: TableInput) {
|
||||
export default function markdownTable(input: TableInput) {
|
||||
return input
|
||||
.filter((array) => array[1] !== undefined)
|
||||
.map((array) => (array.length === 0 ? '' : `**${array[0]}**: ${array[1]}`))
|
||||
@@ -1,6 +0,0 @@
|
||||
import negativeEmbed from './negativeEmbed.js';
|
||||
|
||||
export const noMember = negativeEmbed(
|
||||
'User of command is not a member',
|
||||
'Discord claims that the user of this command does not have an account... strange!',
|
||||
);
|
||||
@@ -1,6 +0,0 @@
|
||||
import negativeEmbed from './negativeEmbed.js';
|
||||
|
||||
export const notTrackedByBlitzStars = negativeEmbed(
|
||||
'No data to display',
|
||||
'Player is not tracked by BlitzStars.',
|
||||
);
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ButtonBuilder, ButtonStyle } from 'discord.js';
|
||||
|
||||
// TODO: ADD THIS AGAIN IMMEDIATELY
|
||||
export const supportBlitzStars = new ButtonBuilder()
|
||||
.setLabel('Support BlitzStars')
|
||||
.setURL('https://www.blitzstars.com/supporters')
|
||||
|
||||
@@ -5,9 +5,9 @@ import {
|
||||
CacheType,
|
||||
ChatInputCommandInteraction,
|
||||
} from 'discord.js';
|
||||
import negativeEmbed from '../../../core/discord/negativeEmbed.js';
|
||||
import embedNegative from '../../../core/discord/embedNegative.js';
|
||||
import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable.js';
|
||||
import warningEmbed from '../../../core/discord/warningEmbed.js';
|
||||
import embedWarning from '../../../core/discord/embedWarning.js';
|
||||
import { psa } from '../../../core/node/psa.js';
|
||||
import { handleError } from '../../error.js';
|
||||
import { commands } from '../index.js';
|
||||
@@ -29,7 +29,7 @@ export default async function handleChatInputCommand(
|
||||
|
||||
if (psa.data) {
|
||||
if (!reply.embeds) reply.embeds = [];
|
||||
reply.embeds.push(warningEmbed(psa.data.title, psa.data.description));
|
||||
reply.embeds.push(embedWarning(psa.data.title, psa.data.description));
|
||||
}
|
||||
|
||||
await interaction.editReply(reply);
|
||||
@@ -43,7 +43,7 @@ export default async function handleChatInputCommand(
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
negativeEmbed(
|
||||
embedNegative(
|
||||
(error as Error).message,
|
||||
`${(error as Error).cause ?? 'No further information is available.'}`,
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user