mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: /debug and /help
This commit is contained in:
1 parent
91260aed2a
commit
c37b90caac
11 files changed
+110
-10
No files matched your search
@@ -13,7 +13,7 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
host:
|
||||||
name: Host
|
name: Host
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sklld-bot",
|
"name": "sklld-bot",
|
||||||
"version": "1.0.0",
|
"version": "0.6.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ export interface CommandRegistry {
|
|||||||
export const rest = new REST().setToken(process.env.DISCORD_TOKEN!);
|
export const rest = new REST().setToken(process.env.DISCORD_TOKEN!);
|
||||||
const commandFolders = readdirSync('src/commands/');
|
const commandFolders = readdirSync('src/commands/');
|
||||||
const commandCollection = new Collection<string, CommandRegistry>();
|
const commandCollection = new Collection<string, CommandRegistry>();
|
||||||
const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
export const guildCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =
|
||||||
const publicCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
[];
|
||||||
|
export const publicCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] =
|
||||||
|
[];
|
||||||
|
|
||||||
for (const file of commandFolders) {
|
for (const file of commandFolders) {
|
||||||
const command = (await import(`../commands/${file}`))
|
const command = (await import(`../commands/${file}`))
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import packageJSON from '../../package.json' assert { type: 'json' };
|
||||||
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
|
import { executionStart } from '../index.js';
|
||||||
|
import getClientId from '../utilities/getClientId.js';
|
||||||
|
import { tankopedia } from '../utilities/tankopedia.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
inProduction: false,
|
||||||
|
inDevelopment: true,
|
||||||
|
inPublic: true,
|
||||||
|
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName('debug')
|
||||||
|
.setDescription('Debug information about the bot'),
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
|
const currentTime = new Date().getTime();
|
||||||
|
const uptime = currentTime - executionStart;
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [
|
||||||
|
new EmbedBuilder()
|
||||||
|
.setTitle('Skilled Bot information')
|
||||||
|
.setColor(SKILLED_COLOR)
|
||||||
|
.setDescription(
|
||||||
|
`**Version**: ${packageJSON.version}\n**Uptime**: ${Math.floor(
|
||||||
|
uptime / 1000 / 60 / 60 / 24,
|
||||||
|
)}d ${Math.floor((uptime / 1000 / 60 / 60) % 24)}h ${Math.floor(
|
||||||
|
(uptime / 1000 / 60) % 60,
|
||||||
|
)}m ${Math.floor((uptime / 1000) % 60)}s ${Math.floor(
|
||||||
|
uptime % 1000,
|
||||||
|
)}ms\n**Tankopedia**: ${
|
||||||
|
tankopedia ? 'cached' : 'not cached'
|
||||||
|
}\n**Client ID**: ${getClientId()}\n**Tag**: ${
|
||||||
|
interaction.client.user.tag
|
||||||
|
}`,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("Displaying bot's debug information");
|
||||||
|
},
|
||||||
|
} satisfies CommandRegistry;
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import discord from '../../discord.json' assert { type: 'json' };
|
||||||
|
import {
|
||||||
|
CommandRegistry,
|
||||||
|
guildCommands,
|
||||||
|
publicCommands,
|
||||||
|
} from '../behaviors/interactionCreate.js';
|
||||||
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
inProduction: false,
|
||||||
|
inDevelopment: true,
|
||||||
|
inPublic: true,
|
||||||
|
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName('help')
|
||||||
|
.setDescription('All the help you need about the bot'),
|
||||||
|
|
||||||
|
async execute(interaction) {
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [
|
||||||
|
new EmbedBuilder()
|
||||||
|
.setTitle('Skilled Bot help')
|
||||||
|
.setColor(SKILLED_COLOR)
|
||||||
|
.setDescription(
|
||||||
|
`**About**\nSkilled Bot provides many useful commands that automate many mundane tasks and provide statistics in just the right may.\Made by TresAbhi from the Skilled [SKLLD] clan.\nGitHub: https://github.com/sklld/bot\nSkilled: ADD THE LINK HERE I FORGOT\n\n**Commands**\n${(interaction.guildId ===
|
||||||
|
discord.guild_id
|
||||||
|
? [...guildCommands, ...publicCommands]
|
||||||
|
: publicCommands
|
||||||
|
)
|
||||||
|
.map((command) => `**/${command.name}**: ${command.description}`)
|
||||||
|
.join(
|
||||||
|
'\n',
|
||||||
|
)})}\n\n*I am a new bot; I may make mistakes and go offline from time to time.*`,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Displaying help information');
|
||||||
|
},
|
||||||
|
} satisfies CommandRegistry;
|
||||||
@@ -11,7 +11,7 @@ const DEFAULT_THRESHOLD = 7;
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
inProduction: true,
|
inProduction: true,
|
||||||
inDevelopment: true,
|
inDevelopment: false,
|
||||||
inPublic: true,
|
inPublic: true,
|
||||||
|
|
||||||
command: new SlashCommandBuilder()
|
command: new SlashCommandBuilder()
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export default {
|
|||||||
(tankData) => tankopedia.data[tankData.tank_id],
|
(tankData) => tankopedia.data[tankData.tank_id],
|
||||||
).filter((tank) => tank.tier === tier);
|
).filter((tank) => tank.tier === tier);
|
||||||
|
|
||||||
interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle(
|
.setTitle(
|
||||||
@@ -80,6 +80,10 @@ export default {
|
|||||||
.setColor(SKILLED_COLOR),
|
.setColor(SKILLED_COLOR),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`Displaying ${account.nickname}'s owned tanks in tier ${tier}`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
} satisfies CommandRegistry;
|
} satisfies CommandRegistry;
|
||||||
@@ -5,6 +5,8 @@ import interactionCreate from './behaviors/interactionCreate.js';
|
|||||||
import ready from './behaviors/ready.js';
|
import ready from './behaviors/ready.js';
|
||||||
import tokenRequirements from './utilities/tokenRequirements.js';
|
import tokenRequirements from './utilities/tokenRequirements.js';
|
||||||
|
|
||||||
|
export const executionStart = new Date().getTime();
|
||||||
|
|
||||||
tokenRequirements();
|
tokenRequirements();
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default async function getBlitzAccount(
|
|||||||
callback(players.data[0]);
|
callback(players.data[0]);
|
||||||
} else {
|
} else {
|
||||||
// no exact match
|
// no exact match
|
||||||
interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(NEGATIVE_COLOR)
|
.setColor(NEGATIVE_COLOR)
|
||||||
@@ -49,5 +49,7 @@ export default async function getBlitzAccount(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`Account not found for ${name} in ${serverName} server.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,8 +13,8 @@ export default async function getBlitzStarsAccount(
|
|||||||
name: string,
|
name: string,
|
||||||
callback: (account: PlayerStatistics) => void,
|
callback: (account: PlayerStatistics) => void,
|
||||||
) {
|
) {
|
||||||
function notTracked() {
|
async function notTracked() {
|
||||||
interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle('No data to display')
|
.setTitle('No data to display')
|
||||||
@@ -22,6 +22,8 @@ export default async function getBlitzStarsAccount(
|
|||||||
.setColor(NEGATIVE_COLOR),
|
.setColor(NEGATIVE_COLOR),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`${name} is not tracked by BlitzStars.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(`https://www.blitzstars.com/api/top/player/${accountId}`)
|
fetch(`https://www.blitzstars.com/api/top/player/${accountId}`)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default async function getClan(
|
|||||||
callback(clans.data[0]);
|
callback(clans.data[0]);
|
||||||
} else {
|
} else {
|
||||||
// no exact match
|
// no exact match
|
||||||
interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(NEGATIVE_COLOR)
|
.setColor(NEGATIVE_COLOR)
|
||||||
@@ -48,5 +48,7 @@ export default async function getClan(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`Clan not found for ${name} in ${serverName} server.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user