feat: rename to blitzkrieg

This commit is contained in:
TresAbhi committed 2023-05-21 16:50:05 +00:00
1 parent c61877a267
commit bc798da88b
19 files changed
+47 -193

No files matched your search

-1
View File
@@ -5,7 +5,6 @@
"kranvagn",
"ownedtanks",
"searchplayers",
"SKLLD",
"Smri",
"strvk",
"tankopedia",
+3 -3
View File
@@ -1,10 +1,10 @@
# Skilled Bot
# blitzkrieg
Executes specific tasks in the Skilled Discord server.
A Discord bot for anything and everything related to World of Tanks Blitz.
## Invite the Bot
Join the [Skilled Discord server](https://discord.gg/ZPvcEG7DS8), click on the bot's profile, and click "Add to Server".
Join the [Discord server](https://discord.gg/nDt7AjGJQH), click on the bot's profile, and click "Add to Server".
## Using
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "sklld-bot",
"name": "blitzkrieg",
"version": "0.6.0",
"description": "",
"main": "index.js",
+3 -3
View File
@@ -1,11 +1,11 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import packageJSON from '../../package.json' assert { type: 'json' };
import { SKILLED_COLOR } from '../constants/colors.js';
import { INFO_COLOR } from '../constants/colors.js';
import { tankopedia } from '../core/blitzstars/tankopedia.js';
import cmdName from '../core/interaction/cmdName.js';
import getClientId from '../core/process/getClientId.js';
import { client } from '../index.js';
import { CommandRegistry } from '../events/interactionCreate.js';
import { client } from '../index.js';
const executionStart = new Date().getTime();
@@ -26,7 +26,7 @@ export default {
embeds: [
new EmbedBuilder()
.setTitle(`${client.user?.username} debug information`)
.setColor(SKILLED_COLOR)
.setColor(INFO_COLOR)
.setDescription(
`**Version**: ${packageJSON.version}\n**Uptime**: ${Math.floor(
uptime / 1000 / 60 / 60 / 24,
-149
View File
@@ -1,149 +0,0 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
import { BlitzServer } from '../constants/servers.js';
import usernameAutocomplete from '../core/autocomplete/username.js';
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
import blitzStarsLinks from '../core/blitzstars/blitzStarsLinks.js';
import getBlitzStarsAccount from '../core/blitzstars/getBlitzStarsAccount.js';
import poweredByBlitzStars from '../core/blitzstars/poweredByBlitzStars.js';
import cmdName from '../core/interaction/cmdName.js';
import addServerChoices from '../core/options/addServerChoices.js';
import addUsernameOption from '../core/options/addUsernameOption.js';
import { CommandRegistry } from '../events/interactionCreate.js';
const CLANS = {
sklld: { id: 71559, name: 'Skilled' },
smri: { id: 91244, name: 'Samurai' },
};
export default {
inProduction: false,
inDevelopment: false,
inPublic: false,
command: new SlashCommandBuilder()
.setName(cmdName('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(addServerChoices)
.addStringOption(addUsernameOption),
async execute(interaction) {
const clan = interaction.options.getString('clan') as keyof typeof CLANS;
const name = interaction.options.getString('username')!;
const server = interaction.options.getString('server') as BlitzServer;
const blitzAccount = await getBlitzAccount(interaction, name, server);
if (!blitzAccount) return;
const blitzStarsAccount = await getBlitzStarsAccount(
interaction,
blitzAccount.account_id,
);
if (!blitzStarsAccount) return;
const issues: string[] = [];
if (clan === 'sklld') {
if (blitzStarsAccount.period30d.all.battles < 150) {
issues.push(
`**Battles**: ${blitzStarsAccount.period30d.all.battles} (${
blitzStarsAccount.period30d.all.battles - 150
})`,
);
}
if (blitzStarsAccount.period30d.avg_tier < 8) {
issues.push(
`**Tier**: ${blitzStarsAccount.period30d.avg_tier.toFixed(2)} (${(
blitzStarsAccount.period30d.avg_tier - 8
).toFixed(2)})`,
);
}
if (blitzStarsAccount.period30d.special.winrate < 60) {
issues.push(
`**Winrate**: ${blitzStarsAccount.period30d.special.winrate.toFixed(
2,
)}% (${(blitzStarsAccount.period30d.special.winrate - 60).toFixed(
2,
)}%)`,
);
}
if (blitzStarsAccount.period30d.wn8 < 2100) {
issues.push(
`**WN8**: ${blitzStarsAccount.period30d.wn8.toFixed(0)} (${(
blitzStarsAccount.period30d.wn8 - 2100
).toFixed(0)})`,
);
}
if (blitzStarsAccount.period30d.special.dpb < 2400) {
issues.push(
`**Damage per battle**: ${blitzStarsAccount.period30d.special.dpb.toFixed(
0,
)} (${(blitzStarsAccount.period30d.special.dpb - 2400).toFixed(0)})`,
);
}
} else {
if (blitzStarsAccount.statistics.all.battles < 1500) {
issues.push(
`**Battles**: ${blitzStarsAccount.statistics.all.battles} (${
blitzStarsAccount.statistics.all.battles - 1500
})`,
);
}
if (blitzStarsAccount.statistics.special.winrate < 53) {
issues.push(
`**Winrate**: ${blitzStarsAccount.statistics.special.winrate.toFixed(
2,
)}% (${(blitzStarsAccount.statistics.special.winrate - 53).toFixed(
2,
)}%)`,
);
}
}
const eligible = issues.length === 0;
await interaction.editReply({
embeds: [
poweredByBlitzStars(
new EmbedBuilder()
.setTitle(
`${markdownEscape(blitzStarsAccount.nickname)} is ${
eligible ? '' : 'not '
}eligible for ${CLANS[clan].name}`,
)
.setColor(eligible ? POSITIVE_COLOR : NEGATIVE_COLOR)
.setDescription(
`${
eligible
? `${markdownEscape(
blitzStarsAccount.nickname,
)} meets all the requirements set for ${CLANS[clan].name}.`
: `${markdownEscape(
blitzStarsAccount.nickname,
)}'s shortcomings for ${CLANS[clan].name} (${
clan === 'sklld' ? '30 days stats' : 'career stats'
}):\n\n${issues.join('\n')}`
}\n\n${blitzStarsLinks(server, blitzAccount.nickname)}`,
),
),
],
});
console.log(
`Showing ${blitzStarsAccount.nickname}'s eligibility for ${CLANS[clan].name}`,
);
},
autocomplete: usernameAutocomplete,
} satisfies CommandRegistry;
+8 -4
View File
@@ -1,9 +1,13 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import discord from '../../discord.json' assert { type: 'json' };
import { SKILLED_COLOR } from '../constants/colors.js';
import { INFO_COLOR } from '../constants/colors.js';
import cmdName from '../core/interaction/cmdName.js';
import {
CommandRegistry,
guildCommands,
publicCommands,
} from '../events/interactionCreate.js';
import { client } from '../index.js';
import { CommandRegistry, guildCommands, publicCommands } from '../events/interactionCreate.js';
export default {
inProduction: true,
@@ -19,11 +23,11 @@ export default {
embeds: [
new EmbedBuilder()
.setTitle(`${client.user?.username} help`)
.setColor(SKILLED_COLOR)
.setColor(INFO_COLOR)
.setDescription(
`**About**\n${
client.user?.username
} automates many mundane tasks and provide statistics in numerous flexible ways.\n\nMade by TresAbhi from the Skilled [SKLLD] clan.\nGitHub: https://github.com/tresabhi/sklld-bot\nDiscord server: https://discord.gg/nDt7AjGJQH\nSkilled server: https://discord.gg/ZPvcEG7DS8\n\n**Commands**\n${(interaction.guildId ===
} automates many mundane tasks and provide statistics in numerous flexible ways.\n\nMade by TresAbhi from the Skilled [SKLLD] clan.\nGitHub: https://github.com/tresabhi/blitzkrieg\nDiscord server: https://discord.gg/nDt7AjGJQH\nSkilled server: https://discord.gg/ZPvcEG7DS8\n\n**Commands**\n${(interaction.guildId ===
discord.sklld_guild_id
? [...guildCommands, ...publicCommands]
: publicCommands
+2 -2
View File
@@ -1,6 +1,6 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { SKILLED_COLOR } from '../constants/colors.js';
import { INFO_COLOR } from '../constants/colors.js';
import usernameAutocomplete from '../core/autocomplete/username.js';
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
@@ -100,7 +100,7 @@ export default {
TANK_TYPE_EMOJIS['AT-SPG']
} = Tank Destroyer`,
)
.setColor(SKILLED_COLOR),
.setColor(INFO_COLOR),
],
});
+2 -2
View File
@@ -6,7 +6,7 @@ import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
import cleanTable, { TableInputEntry } from '../core/interaction/cleanTable.js';
import cmdName from '../core/interaction/cmdName.js';
import sklldEmbed from '../core/interaction/sklldEmbed.js';
import infoEmbed from '../core/interaction/infoEmbed.js';
import addUsernameOption from '../core/options/addUsernameOption.js';
import { args } from '../core/process/args.js';
import { CommandRegistry } from '../events/interactionCreate.js';
@@ -57,7 +57,7 @@ export default {
interaction.editReply({
embeds: [
sklldEmbed(
infoEmbed(
`${markdownEscape(accounts[id].nickname)}'s information`,
cleanTable(
+2 -2
View File
@@ -5,7 +5,7 @@ import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
import cleanTable from '../core/interaction/cleanTable.js';
import cmdName from '../core/interaction/cmdName.js';
import sklldEmbed from '../core/interaction/sklldEmbed.js';
import infoEmbed from '../core/interaction/infoEmbed.js';
import addUsernameOption from '../core/options/addUsernameOption.js';
import { args } from '../core/process/args.js';
import { CommandRegistry } from '../events/interactionCreate.js';
@@ -34,7 +34,7 @@ export default {
interaction.editReply({
embeds: [
sklldEmbed(
infoEmbed(
`${markdownEscape(accountInfo.nickname)}'s information`,
cleanTable([
+3 -3
View File
@@ -3,7 +3,7 @@ import markdownEscape from 'markdown-escape';
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
import cmdName from '../core/interaction/cmdName.js';
import sklldEmbed from '../core/interaction/sklldEmbed.js';
import infoEmbed from '../core/interaction/infoEmbed.js';
import addClanChoices from '../core/options/addClanChoices.js';
import addServerChoices from '../core/options/addServerChoices.js';
import { args } from '../core/process/args.js';
@@ -12,7 +12,7 @@ import { ClanList } from '../types/clanList.js';
export default {
inProduction: true,
inDevelopment: true,
inDevelopment: false,
inPublic: true,
command: new SlashCommandBuilder()
@@ -39,7 +39,7 @@ export default {
await interaction.editReply({
embeds: [
sklldEmbed(
infoEmbed(
`Clan search for "${markdownEscape(clan)}" in ${
BLITZ_SERVERS[server]
}`,
+2 -2
View File
@@ -1,6 +1,6 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { SKILLED_COLOR } from '../constants/colors.js';
import { INFO_COLOR } from '../constants/colors.js';
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
import cmdName from '../core/interaction/cmdName.js';
@@ -42,7 +42,7 @@ export default {
await interaction.editReply({
embeds: [
new EmbedBuilder()
.setColor(SKILLED_COLOR)
.setColor(INFO_COLOR)
.setTitle(
`Player search for "${markdownEscape(name)}" in ${
BLITZ_SERVERS[server]
+2 -2
View File
@@ -3,7 +3,7 @@ import { go } from 'fuzzysort';
import markdownEscape from 'markdown-escape';
import { tankNames } from '../core/blitzstars/tankopedia.js';
import cmdName from '../core/interaction/cmdName.js';
import sklldEmbed from '../core/interaction/sklldEmbed.js';
import infoEmbed from '../core/interaction/infoEmbed.js';
import addTankChoices from '../core/options/addTankChoices.js';
import { CommandRegistry } from '../events/interactionCreate.js';
@@ -33,7 +33,7 @@ export default {
await interaction.editReply({
embeds: [
sklldEmbed(
infoEmbed(
`Tank search for "${markdownEscape(tank)}"`,
results.length === 0
? 'No tanks found.'
+2 -2
View File
@@ -1,6 +1,6 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { SKILLED_COLOR } from '../constants/colors.js';
import { INFO_COLOR } from '../constants/colors.js';
import usernameAutocomplete from '../core/autocomplete/username.js';
import getBlitzAccount from '../core/blitz/getBlitzAccount.js';
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
@@ -103,7 +103,7 @@ export default {
embeds: [
poweredByBlitzStars(
new EmbedBuilder()
.setColor(SKILLED_COLOR)
.setColor(INFO_COLOR)
.setTitle(
`${markdownEscape(blitzStarsAccount.nickname)}'s ${
period === 'career'
+2 -2
View File
@@ -11,7 +11,7 @@ import getPeriodicStats, {
import cleanTable from '../core/interaction/cleanTable.js';
import cmdName from '../core/interaction/cmdName.js';
import errorEmbed from '../core/interaction/errorEmbed.js';
import sklldEmbed from '../core/interaction/sklldEmbed.js';
import infoEmbed from '../core/interaction/infoEmbed.js';
import addTankChoices from '../core/options/addTankChoices.js';
import addUsernameOption from '../core/options/addUsernameOption.js';
import { args } from '../core/process/args.js';
@@ -79,7 +79,7 @@ export default {
interaction.editReply({
embeds: [
sklldEmbed(
infoEmbed(
`${period} day stats for ${markdownEscape(
accountInfo[id].nickname,
)}'s ${resolveTankName(tank)}`,
+1 -1
View File
@@ -1,3 +1,3 @@
export const SKILLED_COLOR = '#8e3cf5';
export const INFO_COLOR = '#8e3cf5';
export const POSITIVE_COLOR = '#82ff29';
export const NEGATIVE_COLOR = '#ff4747';
+9
View File
@@ -0,0 +1,9 @@
import { EmbedBuilder } from 'discord.js';
import { INFO_COLOR } from '../../constants/colors.js';
export default function infoEmbed(title: string, description: string) {
return new EmbedBuilder()
.setColor(INFO_COLOR)
.setTitle(title)
.setDescription(description);
}
-9
View File
@@ -1,9 +0,0 @@
import { EmbedBuilder } from 'discord.js';
import { SKILLED_COLOR } from '../../constants/colors.js';
export default function sklldEmbed(title: string, description: string) {
return new EmbedBuilder()
.setColor(SKILLED_COLOR)
.setTitle(title)
.setDescription(description);
}
+2 -2
View File
@@ -1,6 +1,6 @@
import { EmbedBuilder, GuildMember, TextChannel } from 'discord.js';
import discord from '../../discord.json' assert { type: 'json' };
import { SKILLED_COLOR } from '../constants/colors.js';
import { INFO_COLOR } from '../constants/colors.js';
export default async function (member: GuildMember) {
if (member.guild.id === discord.sklld_guild_id) {
@@ -12,7 +12,7 @@ export default async function (member: GuildMember) {
content: member.toString(),
embeds: [
new EmbedBuilder()
.setColor(SKILLED_COLOR)
.setColor(INFO_COLOR)
.setTitle(`Welcome ${member.user.username}`)
.setDescription(
`Welcome to the Skilled server, **${member.user.username}**! To continue, please use the \`/verify\` command.\n\nExample: \`/verify Europe Sabina244\``,
+3 -3
View File
@@ -16,9 +16,9 @@ import getClientId from '../core/process/getClientId.js';
import isDev from '../core/process/isDev.js';
export interface CommandRegistry {
inDevelopment: boolean; // register with Skilled Bot (default: false)
inProduction: boolean; // register with Skilled Canary (default: false)
inPublic: boolean; // registers on all servers (default: true)
inDevelopment: boolean;
inProduction: boolean;
inPublic: boolean;
command: Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
execute: (interaction: ChatInputCommandInteraction<CacheType>) => void;