mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 22:16:13 +00:00
fix: Fixed annotations
This commit is contained in:
1 parent
0d9f4bd404
commit
89f8e2d0d1
6 files changed
+55
-21
No files matched your search
@@ -1,11 +1,12 @@
|
||||
import 'dotenv/config';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { REST, Routes } from 'discord.js';
|
||||
import { REST, RouteLike, Routes, SlashCommandBuilder } from 'discord.js';
|
||||
import config from 'config';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import loggerModule from '../services/logger';
|
||||
const systemOptions = config.get('systemOptions');
|
||||
import { SystemOptions } from '../types/configTypes';
|
||||
const systemOptions: SystemOptions = config.get('systemOptions');
|
||||
|
||||
const executionId = uuidv4();
|
||||
|
||||
@@ -16,8 +17,8 @@ const logger = loggerModule.child({
|
||||
executionId: executionId
|
||||
});
|
||||
|
||||
const slashCommands = [];
|
||||
const systemCommands = [];
|
||||
const slashCommands: SlashCommandBuilder[] = [];
|
||||
const systemCommands: SlashCommandBuilder[] = [];
|
||||
const commandFolders = fs.readdirSync(path.resolve('./dist/commands'));
|
||||
for (const folder of commandFolders) {
|
||||
const commandFiles = fs
|
||||
@@ -33,6 +34,14 @@ for (const folder of commandFolders) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!process.env.DISCORD_BOT_TOKEN) {
|
||||
throw new Error('DISCORD_BOT_TOKEN environment variable is not set.');
|
||||
}
|
||||
|
||||
if (!process.env.DISCORD_APPLICATION_ID) {
|
||||
throw new Error('DISCORD_APPLICATION_ID environment variable is not set.');
|
||||
}
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN);
|
||||
|
||||
(async () => {
|
||||
@@ -46,7 +55,7 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
|
||||
logger.debug(`Bot user slash commands found: ${slashCommands.map((command) => `/${command.name}`).join(', ')}`);
|
||||
|
||||
logger.info('Started refreshing user slash commands.');
|
||||
await refreshCommands(Routes.applicationCommands(process.env.DISCORD_APPLICATION_ID), slashCommands);
|
||||
await refreshCommands(Routes.applicationCommands(process.env.DISCORD_APPLICATION_ID!), slashCommands);
|
||||
logger.info('Successfully refreshed user slash commands.');
|
||||
} catch (error) {
|
||||
logger.error(error, 'Failed to refresh user slash commands.');
|
||||
@@ -62,10 +71,10 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
|
||||
logger.info('Started refreshing system slash commands.');
|
||||
const systemGuildIds = systemOptions.systemGuildIds;
|
||||
await Promise.all(
|
||||
systemGuildIds.map((systemGuildId) => {
|
||||
systemGuildIds.map((systemGuildId: string) => {
|
||||
logger.debug(`Refreshing system slash command for guild id '${systemGuildId}'.`);
|
||||
refreshCommands(
|
||||
Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID, systemGuildId),
|
||||
Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID!, systemGuildId),
|
||||
systemCommands
|
||||
);
|
||||
})
|
||||
@@ -79,6 +88,6 @@ const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_TOKEN)
|
||||
}
|
||||
})();
|
||||
|
||||
async function refreshCommands(route, commands) {
|
||||
async function refreshCommands(route: RouteLike, commands: object[]) {
|
||||
await rest.put(route, { body: commands });
|
||||
}
|
||||
Reference in new issue
Block a user