mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: infastructure for public
This commit is contained in:
1 parent
ab725c7f86
commit
468bca77de
6 files changed
+252
-213
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
CacheType,
|
CacheType,
|
||||||
|
ChatInputCommandInteraction,
|
||||||
Collection,
|
Collection,
|
||||||
Interaction,
|
Interaction,
|
||||||
REST,
|
REST,
|
||||||
@@ -13,34 +14,53 @@ import getClientId from '../utilities/getClientId.js';
|
|||||||
import isDev from '../utilities/isDev.js';
|
import isDev from '../utilities/isDev.js';
|
||||||
|
|
||||||
export interface CommandRegistry {
|
export interface CommandRegistry {
|
||||||
inDev?: boolean;
|
inDevelopment: boolean; // register with Skilled Bot (default: false)
|
||||||
data: SlashCommandBuilder;
|
inProduction: boolean; // register with Skilled Canary (default: false)
|
||||||
execute: (interaction: Interaction) => void;
|
inPublic: boolean; // registers on all servers (default: true)
|
||||||
|
|
||||||
|
command: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
||||||
|
execute: (interaction: ChatInputCommandInteraction<CacheType>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const commandCollection = new Collection<string, CommandRegistry>();
|
|
||||||
const commands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
|
||||||
const commandFolders = readdirSync('src/commands/');
|
|
||||||
const rest = new REST().setToken(process.env.DISCORD_TOKEN!);
|
const rest = new REST().setToken(process.env.DISCORD_TOKEN!);
|
||||||
|
const commandFolders = readdirSync('src/commands/');
|
||||||
|
const commandCollection = new Collection<string, CommandRegistry>();
|
||||||
|
const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
||||||
|
const publicCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
||||||
|
|
||||||
for (const file of commandFolders) {
|
for (const file of commandFolders) {
|
||||||
const command = (await import(`../commands/${file}`)) as CommandRegistry;
|
const command = (await import(`../commands/${file}`))
|
||||||
|
.default as CommandRegistry;
|
||||||
|
|
||||||
if (isDev() ? command.inDev ?? false : true) {
|
if (isDev() ? command.inDevelopment : command.inProduction) {
|
||||||
commands.push(command.data.toJSON());
|
if (command.inPublic) {
|
||||||
commandCollection.set(command.data.name, command);
|
publicCommands.push(command.command.toJSON());
|
||||||
|
} else {
|
||||||
|
guildCommands.push(command.command.toJSON());
|
||||||
|
}
|
||||||
|
|
||||||
|
commandCollection.set(command.command.name, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(`Started refreshing ${commands.length} command(s).`);
|
console.log(`Refreshing ${guildCommands.length} guild command(s).`);
|
||||||
|
|
||||||
const data = (await rest.put(
|
const guildData = (await rest.put(
|
||||||
Routes.applicationGuildCommands(getClientId(), discord.guild_id),
|
Routes.applicationGuildCommands(getClientId(), discord.guild_id),
|
||||||
{ body: commands },
|
{ body: guildCommands },
|
||||||
)) as RESTPostAPIChatInputApplicationCommandsJSONBody[];
|
)) as RESTPostAPIChatInputApplicationCommandsJSONBody[];
|
||||||
|
|
||||||
console.log(`Successfully reloaded ${data.length} command(s).`);
|
console.log(`Successfully refreshed ${guildData.length} guild command(s).`);
|
||||||
|
|
||||||
|
console.log(`Refreshing ${publicCommands.length} public command(s).`);
|
||||||
|
|
||||||
|
const publicData = (await rest.put(
|
||||||
|
Routes.applicationCommands(getClientId()),
|
||||||
|
{ body: publicCommands },
|
||||||
|
)) as RESTPostAPIChatInputApplicationCommandsJSONBody[];
|
||||||
|
|
||||||
|
console.log(`Successfully refreshed ${publicData.length} public command(s).`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-49
@@ -1,9 +1,5 @@
|
|||||||
import {
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
CacheType,
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
ChatInputCommandInteraction,
|
|
||||||
EmbedBuilder,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from 'discord.js';
|
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import blitzLinks from '../utilities/blitzLinks.js';
|
import blitzLinks from '../utilities/blitzLinks.js';
|
||||||
@@ -22,15 +18,53 @@ export const CLANS = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function execute(
|
export default {
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
inProduction: true,
|
||||||
) {
|
inDevelopment: false,
|
||||||
|
inPublic: false,
|
||||||
|
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName('eligible')
|
||||||
|
.setDescription("Gets the user's eligibility for Skilled clans")
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('clan')
|
||||||
|
.setDescription('The Skilled clan you are checking')
|
||||||
|
.addChoices(
|
||||||
|
{ name: CLANS.sklld.name, value: 'sklld' },
|
||||||
|
{ name: CLANS.smri.name, value: 'smri' },
|
||||||
|
)
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('server')
|
||||||
|
.setDescription('The Blitz server you are in')
|
||||||
|
.addChoices(
|
||||||
|
{ name: BLITZ_SERVERS.com, value: 'com' },
|
||||||
|
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
||||||
|
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
||||||
|
)
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('ign')
|
||||||
|
.setDescription('The username you use in Blitz')
|
||||||
|
.setRequired(true),
|
||||||
|
),
|
||||||
|
|
||||||
|
execute(interaction) {
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
const server = interaction.options.getString('server') as BlitzServer;
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
const clan = interaction.options.getString('clan') as keyof typeof CLANS;
|
const clan = interaction.options.getString('clan') as keyof typeof CLANS;
|
||||||
|
|
||||||
getBlitzAccount(interaction, ign, server, async (account) => {
|
getBlitzAccount(interaction, ign, server, async (account) => {
|
||||||
getBlitzStarsAccount(interaction, account.account_id, ign, async (data) => {
|
getBlitzStarsAccount(
|
||||||
|
interaction,
|
||||||
|
account.account_id,
|
||||||
|
ign,
|
||||||
|
async (data) => {
|
||||||
const issues: string[] = [];
|
const issues: string[] = [];
|
||||||
|
|
||||||
if (clan === 'sklld') {
|
if (clan === 'sklld') {
|
||||||
@@ -79,9 +113,9 @@ export async function execute(
|
|||||||
}
|
}
|
||||||
if (data.statistics.special.winrate < 53) {
|
if (data.statistics.special.winrate < 53) {
|
||||||
issues.push(
|
issues.push(
|
||||||
`**Winrate**: ${data.statistics.special.winrate.toFixed(2)}% (${(
|
`**Winrate**: ${data.statistics.special.winrate.toFixed(
|
||||||
data.statistics.special.winrate - 53
|
2,
|
||||||
).toFixed(2)}%)`,
|
)}% (${(data.statistics.special.winrate - 53).toFixed(2)}%)`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,9 +127,9 @@ export async function execute(
|
|||||||
poweredByBlitzStars(
|
poweredByBlitzStars(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle(
|
.setTitle(
|
||||||
`${data.nickname} is ${eligible ? '' : 'not '}eligible for ${
|
`${data.nickname} is ${
|
||||||
CLANS[clan].name
|
eligible ? '' : 'not '
|
||||||
}`,
|
}eligible for ${CLANS[clan].name}`,
|
||||||
)
|
)
|
||||||
.setColor(eligible ? POSITIVE_COLOR : NEGATIVE_COLOR)
|
.setColor(eligible ? POSITIVE_COLOR : NEGATIVE_COLOR)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
@@ -116,37 +150,8 @@ export async function execute(
|
|||||||
console.log(
|
console.log(
|
||||||
`Showing ${data.nickname}'s eligibility for ${CLANS[clan].name}`,
|
`Showing ${data.nickname}'s eligibility for ${CLANS[clan].name}`,
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
|
||||||
.setName('eligible')
|
|
||||||
.setDescription("Gets the user's eligibility for Skilled clans")
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('clan')
|
|
||||||
.setDescription('The Skilled clan you are checking')
|
|
||||||
.addChoices(
|
|
||||||
{ name: CLANS.sklld.name, value: 'sklld' },
|
|
||||||
{ name: CLANS.smri.name, value: 'smri' },
|
|
||||||
)
|
|
||||||
.setRequired(true),
|
|
||||||
)
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('server')
|
|
||||||
.setDescription('The Blitz server you are in')
|
|
||||||
.addChoices(
|
|
||||||
{ name: BLITZ_SERVERS.com, value: 'com' },
|
|
||||||
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
|
||||||
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
|
||||||
)
|
|
||||||
.setRequired(true),
|
|
||||||
)
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('ign')
|
|
||||||
.setDescription('The username you use in Blitz')
|
|
||||||
.setRequired(true),
|
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
} satisfies CommandRegistry;
|
||||||
+35
-33
@@ -1,10 +1,6 @@
|
|||||||
import {
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
CacheType,
|
|
||||||
ChatInputCommandInteraction,
|
|
||||||
EmbedBuilder,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from 'discord.js';
|
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { ClanDetails } from '../types/clanDetails.js';
|
import { ClanDetails } from '../types/clanDetails.js';
|
||||||
import { PlayerPersonalData } from '../types/playerPersonalData.js';
|
import { PlayerPersonalData } from '../types/playerPersonalData.js';
|
||||||
@@ -12,13 +8,40 @@ import { CLANS } from './eligible.js';
|
|||||||
|
|
||||||
const DEFAULT_THRESHOLD = 7;
|
const DEFAULT_THRESHOLD = 7;
|
||||||
|
|
||||||
export async function execute(
|
export default {
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
inProduction: true,
|
||||||
) {
|
inDevelopment: false,
|
||||||
|
inPublic: false,
|
||||||
|
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName('inactive')
|
||||||
|
.setDescription('Lists all inactive players')
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('clan')
|
||||||
|
.setDescription('The Skilled clan you are checking')
|
||||||
|
.addChoices(
|
||||||
|
{ name: CLANS.sklld.name, value: 'sklld' },
|
||||||
|
{ name: CLANS.smri.name, value: 'smri' },
|
||||||
|
)
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
|
.addNumberOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('threshold')
|
||||||
|
.setDescription(
|
||||||
|
`The number of days inactive (default: ${DEFAULT_THRESHOLD})`,
|
||||||
|
)
|
||||||
|
.setMinValue(0),
|
||||||
|
),
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
const threshold =
|
const threshold =
|
||||||
interaction.options.getNumber('threshold')! ?? DEFAULT_THRESHOLD;
|
interaction.options.getNumber('threshold')! ?? DEFAULT_THRESHOLD;
|
||||||
const time = new Date().getTime() / 1000;
|
const time = new Date().getTime() / 1000;
|
||||||
const clanName = interaction.options.getString('clan') as keyof typeof CLANS;
|
const clanName = interaction.options.getString(
|
||||||
|
'clan',
|
||||||
|
) as keyof typeof CLANS;
|
||||||
const clanData = (await (
|
const clanData = (await (
|
||||||
await fetch(
|
await fetch(
|
||||||
`https://api.wotblitz.com/wotb/clans/info/?application_id=${process.env.WARGAMING_APPLICATION_ID}&clan_id=${CLANS[clanName].id}`,
|
`https://api.wotblitz.com/wotb/clans/info/?application_id=${process.env.WARGAMING_APPLICATION_ID}&clan_id=${CLANS[clanName].id}`,
|
||||||
@@ -71,26 +94,5 @@ export async function execute(
|
|||||||
console.log(
|
console.log(
|
||||||
`Displaying inactive members in ${CLANS[clanName].name} for ${threshold} days`,
|
`Displaying inactive members in ${CLANS[clanName].name} for ${threshold} days`,
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
} satisfies CommandRegistry;
|
||||||
export const data = new SlashCommandBuilder()
|
|
||||||
.setName('inactive')
|
|
||||||
.setDescription('Lists all inactive players')
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('clan')
|
|
||||||
.setDescription('The Skilled clan you are checking')
|
|
||||||
.addChoices(
|
|
||||||
{ name: CLANS.sklld.name, value: 'sklld' },
|
|
||||||
{ name: CLANS.smri.name, value: 'smri' },
|
|
||||||
)
|
|
||||||
.setRequired(true),
|
|
||||||
)
|
|
||||||
.addNumberOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('threshold')
|
|
||||||
.setDescription(
|
|
||||||
`The number of days inactive (default: ${DEFAULT_THRESHOLD})`,
|
|
||||||
)
|
|
||||||
.setMinValue(0),
|
|
||||||
);
|
|
||||||
+56
-46
@@ -1,9 +1,5 @@
|
|||||||
import {
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
CacheType,
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
ChatInputCommandInteraction,
|
|
||||||
EmbedBuilder,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from 'discord.js';
|
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import blitzLinks from '../utilities/blitzLinks.js';
|
import blitzLinks from '../utilities/blitzLinks.js';
|
||||||
@@ -11,9 +7,44 @@ import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
|||||||
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
import getBlitzStarsAccount from '../utilities/getBlitzStarsAccount.js';
|
||||||
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
import poweredByBlitzStars from '../utilities/poweredByBlitzStars.js';
|
||||||
|
|
||||||
export async function execute(
|
export default {
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
inProduction: true,
|
||||||
) {
|
inDevelopment: true,
|
||||||
|
inPublic: true,
|
||||||
|
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName('stats')
|
||||||
|
.setDescription("Gets the user's in-game statistics")
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('period')
|
||||||
|
.setDescription('The last number of days of stats')
|
||||||
|
.setChoices(
|
||||||
|
{ name: '30 Days', value: '30' },
|
||||||
|
{ name: '90 Days', value: '90' },
|
||||||
|
{ name: 'Career', value: 'career' },
|
||||||
|
)
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('server')
|
||||||
|
.setDescription('The Blitz server you are in')
|
||||||
|
.addChoices(
|
||||||
|
{ name: BLITZ_SERVERS.com, value: 'com' },
|
||||||
|
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
||||||
|
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
||||||
|
)
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('ign')
|
||||||
|
.setDescription('The username you use in Blitz')
|
||||||
|
.setRequired(true),
|
||||||
|
),
|
||||||
|
|
||||||
|
execute(interaction) {
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
const server = interaction.options.getString('server') as BlitzServer;
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
const period = interaction.options.getString('period')! as
|
const period = interaction.options.getString('period')! as
|
||||||
@@ -22,7 +53,11 @@ export async function execute(
|
|||||||
| 'career';
|
| 'career';
|
||||||
|
|
||||||
getBlitzAccount(interaction, ign, server, async (account) => {
|
getBlitzAccount(interaction, ign, server, async (account) => {
|
||||||
getBlitzStarsAccount(interaction, account.account_id, ign, async (data) => {
|
getBlitzStarsAccount(
|
||||||
|
interaction,
|
||||||
|
account.account_id,
|
||||||
|
ign,
|
||||||
|
async (data) => {
|
||||||
{
|
{
|
||||||
const stats =
|
const stats =
|
||||||
period === 'career' ? data.statistics : data[`period${period}d`];
|
period === 'career' ? data.statistics : data[`period${period}d`];
|
||||||
@@ -40,7 +75,10 @@ export async function execute(
|
|||||||
.setDescription(
|
.setDescription(
|
||||||
`${[
|
`${[
|
||||||
['Winrate', `${stats.special.winrate.toFixed(2)}%`],
|
['Winrate', `${stats.special.winrate.toFixed(2)}%`],
|
||||||
['Survival', `${stats.special.survivalRate.toFixed(2)}%`],
|
[
|
||||||
|
'Survival',
|
||||||
|
`${stats.special.survivalRate.toFixed(2)}%`,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'Accuracy',
|
'Accuracy',
|
||||||
`${((stats.all.hits / stats.all.shots) * 100).toFixed(
|
`${((stats.all.hits / stats.all.shots) * 100).toFixed(
|
||||||
@@ -76,7 +114,9 @@ export async function execute(
|
|||||||
['Kills to death ratio', stats.special.kdr.toFixed(2)],
|
['Kills to death ratio', stats.special.kdr.toFixed(2)],
|
||||||
]
|
]
|
||||||
.map((array) =>
|
.map((array) =>
|
||||||
array.length === 0 ? '' : `**${array[0]}**: ${array[1]}`,
|
array.length === 0
|
||||||
|
? ''
|
||||||
|
: `**${array[0]}**: ${array[1]}`,
|
||||||
)
|
)
|
||||||
.join('\n')}\n\n${blitzLinks(data)}`,
|
.join('\n')}\n\n${blitzLinks(data)}`,
|
||||||
),
|
),
|
||||||
@@ -86,38 +126,8 @@ export async function execute(
|
|||||||
|
|
||||||
console.log(`Showing ${data.nickname}'s ${period} stats`);
|
console.log(`Showing ${data.nickname}'s ${period} stats`);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export const data = new SlashCommandBuilder()
|
|
||||||
.setName('stats')
|
|
||||||
.setDescription("Gets the user's in-game statistics")
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('period')
|
|
||||||
.setDescription('The last number of days of stats')
|
|
||||||
.setChoices(
|
|
||||||
{ name: '30 Days', value: '30' },
|
|
||||||
{ name: '90 Days', value: '90' },
|
|
||||||
{ name: 'Career', value: 'career' },
|
|
||||||
)
|
|
||||||
.setRequired(true),
|
|
||||||
)
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('server')
|
|
||||||
.setDescription('The Blitz server you are in')
|
|
||||||
.addChoices(
|
|
||||||
{ name: BLITZ_SERVERS.com, value: 'com' },
|
|
||||||
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
|
||||||
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
|
||||||
)
|
|
||||||
.setRequired(true),
|
|
||||||
)
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('ign')
|
|
||||||
.setDescription('The username you use in Blitz')
|
|
||||||
.setRequired(true),
|
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
} satisfies CommandRegistry;
|
||||||
+39
-39
@@ -1,19 +1,47 @@
|
|||||||
import {
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
CacheType,
|
|
||||||
ChatInputCommandInteraction,
|
|
||||||
EmbedBuilder,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from 'discord.js';
|
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import { TanksStats } from '../types/tanksStats.js';
|
import { TanksStats } from '../types/tanksStats.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||||
import { tankTypeEmojis, tankopedia } from '../utilities/tankopedia.js';
|
import { tankTypeEmojis, tankopedia } from '../utilities/tankopedia.js';
|
||||||
|
|
||||||
export async function execute(
|
export default {
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
inProduction: true,
|
||||||
) {
|
inDevelopment: false,
|
||||||
|
inPublic: true,
|
||||||
|
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName('tanks')
|
||||||
|
.setDescription("Shows a player's owned tanks")
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('server')
|
||||||
|
.setDescription('The Blitz server you are in')
|
||||||
|
.setRequired(true)
|
||||||
|
.addChoices(
|
||||||
|
{ name: BLITZ_SERVERS.com, value: 'com' },
|
||||||
|
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
||||||
|
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('ign')
|
||||||
|
.setDescription('The username you use in Blitz')
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
|
.addNumberOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('tier')
|
||||||
|
.setDescription('The tier you want to see (default: all tiers)')
|
||||||
|
.setMinValue(1)
|
||||||
|
.setMaxValue(10)
|
||||||
|
.setRequired(true),
|
||||||
|
),
|
||||||
|
|
||||||
|
execute(interaction) {
|
||||||
const server = interaction.options.getString('server') as BlitzServer;
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
const tier = Math.round(interaction.options.getNumber('tier')!);
|
const tier = Math.round(interaction.options.getNumber('tier')!);
|
||||||
@@ -53,33 +81,5 @@ export async function execute(
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
} satisfies CommandRegistry;
|
||||||
export const data = new SlashCommandBuilder()
|
|
||||||
.setName('tanks')
|
|
||||||
.setDescription("Shows a player's owned tanks")
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('server')
|
|
||||||
.setDescription('The Blitz server you are in')
|
|
||||||
.setRequired(true)
|
|
||||||
.addChoices(
|
|
||||||
{ name: BLITZ_SERVERS.com, value: 'com' },
|
|
||||||
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
|
||||||
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('ign')
|
|
||||||
.setDescription('The username you use in Blitz')
|
|
||||||
.setRequired(true),
|
|
||||||
)
|
|
||||||
.addNumberOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('tier')
|
|
||||||
.setDescription('The tier you want to see (default: all tiers)')
|
|
||||||
.setMinValue(1)
|
|
||||||
.setMaxValue(10)
|
|
||||||
.setRequired(true),
|
|
||||||
);
|
|
||||||
+34
-32
@@ -1,19 +1,39 @@
|
|||||||
import {
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
CacheType,
|
|
||||||
ChatInputCommandInteraction,
|
|
||||||
EmbedBuilder,
|
|
||||||
SlashCommandBuilder,
|
|
||||||
} from 'discord.js';
|
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import discord from '../../discord.json' assert { type: 'json' };
|
import discord from '../../discord.json' assert { type: 'json' };
|
||||||
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import { PlayerClanData } from '../types/playerClanData.js';
|
import { PlayerClanData } from '../types/playerClanData.js';
|
||||||
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
import getBlitzAccount from '../utilities/getBlitzAccount.js';
|
||||||
|
|
||||||
export async function execute(
|
export default {
|
||||||
interaction: ChatInputCommandInteraction<CacheType>,
|
inProduction: true,
|
||||||
) {
|
inDevelopment: false,
|
||||||
|
inPublic: false,
|
||||||
|
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName('verify')
|
||||||
|
.setDescription('Verifies the user with Blitz')
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('server')
|
||||||
|
.setDescription('The Blitz server you are in')
|
||||||
|
.setRequired(true)
|
||||||
|
.addChoices(
|
||||||
|
{ name: BLITZ_SERVERS.com, value: 'com' },
|
||||||
|
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
||||||
|
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName('ign')
|
||||||
|
.setDescription('The username you use in Blitz')
|
||||||
|
.setRequired(true),
|
||||||
|
),
|
||||||
|
|
||||||
|
execute(interaction) {
|
||||||
const ign = interaction.options.getString('ign')!;
|
const ign = interaction.options.getString('ign')!;
|
||||||
const server = interaction.options.getString('server') as BlitzServer;
|
const server = interaction.options.getString('server') as BlitzServer;
|
||||||
|
|
||||||
@@ -40,7 +60,9 @@ export async function execute(
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(POSITIVE_COLOR)
|
.setColor(POSITIVE_COLOR)
|
||||||
.setTitle(`${interaction.user.username} is verified`)
|
.setTitle(`${interaction.user.username} is verified`)
|
||||||
.setDescription(`The user is now verified as ${ign}${clanTag}`),
|
.setDescription(
|
||||||
|
`The user is now verified as ${ign}${clanTag}`,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,25 +88,5 @@ export async function execute(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
} satisfies CommandRegistry;
|
||||||
export const data = new SlashCommandBuilder()
|
|
||||||
.setName('verify')
|
|
||||||
.setDescription('Verifies the user with Blitz')
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('server')
|
|
||||||
.setDescription('The Blitz server you are in')
|
|
||||||
.setRequired(true)
|
|
||||||
.addChoices(
|
|
||||||
{ name: BLITZ_SERVERS.com, value: 'com' },
|
|
||||||
{ name: BLITZ_SERVERS.eu, value: 'eu' },
|
|
||||||
{ name: BLITZ_SERVERS.asia, value: 'asia' },
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.addStringOption((option) =>
|
|
||||||
option
|
|
||||||
.setName('ign')
|
|
||||||
.setDescription('The username you use in Blitz')
|
|
||||||
.setRequired(true),
|
|
||||||
);
|
|
||||||
Reference in new issue
Block a user