mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
small changes
This commit is contained in:
1 parent
1220ef171f
commit
6fb370147e
3 files changed
+14
-15
No files matched your search
@@ -31,7 +31,6 @@ class LyricsAutocomplete extends BaseAutocompleteInteraction {
|
|||||||
|
|
||||||
const genius = lyricsExtractor();
|
const genius = lyricsExtractor();
|
||||||
const lyricsResult: LyricsData = (await genius.search(query).catch(() => null)) as LyricsData;
|
const lyricsResult: LyricsData = (await genius.search(query).catch(() => null)) as LyricsData;
|
||||||
// TODO: Update TS Type for lyricsResult and create response object type
|
|
||||||
let response: ApplicationCommandOptionChoiceData<string>[] = [];
|
let response: ApplicationCommandOptionChoiceData<string>[] = [];
|
||||||
|
|
||||||
if (!lyricsResult) {
|
if (!lyricsResult) {
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ class ShardsCommand extends BaseSlashCommandInteraction {
|
|||||||
(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)
|
(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: Create shardInfo type
|
const shardInfo: ShardInfo = {
|
||||||
const shardInfo = {
|
|
||||||
shardId: shardClient.shard!.ids[0],
|
shardId: shardClient.shard!.ids[0],
|
||||||
memUsage: nodeProcessMemUsageInMb,
|
memUsage: nodeProcessMemUsageInMb,
|
||||||
guildCount: shardClient.guilds.cache.size,
|
guildCount: shardClient.guilds.cache.size,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { randomUUID as uuidv4 } from 'node:crypto';
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { Logger } from 'pino';
|
import { Logger } from 'pino';
|
||||||
|
import { BaseSlashCommandInteraction } from '../classes/interactions';
|
||||||
import loggerModule from '../services/logger';
|
import loggerModule from '../services/logger';
|
||||||
import { SystemOptions } from '../types/configTypes';
|
import { SystemOptions } from '../types/configTypes';
|
||||||
|
|
||||||
@@ -17,10 +18,8 @@ const logger: Logger = loggerModule.child({
|
|||||||
executionId: executionId
|
executionId: executionId
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO: Fix deploying not working with require()
|
const userSlashCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
||||||
|
const systemSlashCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
||||||
const slashCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
|
||||||
const systemCommands: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
|
|
||||||
const commandFolders: string[] = fs.readdirSync(path.resolve('./dist/interactions/commands'));
|
const commandFolders: string[] = fs.readdirSync(path.resolve('./dist/interactions/commands'));
|
||||||
|
|
||||||
if (!process.env.DISCORD_BOT_TOKEN) {
|
if (!process.env.DISCORD_BOT_TOKEN) {
|
||||||
@@ -47,19 +46,21 @@ const rest: REST = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_
|
|||||||
.filter((file) => file.endsWith('.js'));
|
.filter((file) => file.endsWith('.js'));
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
// TODO: create commandModule type
|
|
||||||
const { default: command } = await import(`../interactions/commands/${folder}/${file}`);
|
const { default: command } = await import(`../interactions/commands/${folder}/${file}`);
|
||||||
command.isSystemCommand
|
const slashCommand = command as BaseSlashCommandInteraction;
|
||||||
? systemCommands.push(command.data.toJSON())
|
slashCommand.isSystemCommand
|
||||||
: slashCommands.push(command.data.toJSON());
|
? systemSlashCommands.push(slashCommand.data.toJSON())
|
||||||
|
: userSlashCommands.push(slashCommand.data.toJSON());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.debug(`Bot user slash commands found: ${slashCommands.map((command) => `/${command.name}`).join(', ')}`);
|
logger.debug(
|
||||||
|
`Bot user slash commands found: ${userSlashCommands.map((command) => `/${command.name}`).join(', ')}`
|
||||||
|
);
|
||||||
|
|
||||||
logger.info('Started refreshing user slash commands.');
|
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!), userSlashCommands);
|
||||||
logger.info('Successfully refreshed user slash commands.');
|
logger.info('Successfully refreshed user slash commands.');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error, 'Failed to refresh user slash commands.');
|
logger.error(error, 'Failed to refresh user slash commands.');
|
||||||
@@ -67,7 +68,7 @@ const rest: REST = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Bot system slash commands found: ${systemCommands
|
`Bot system slash commands found: ${systemSlashCommands
|
||||||
.map((systemCommand) => `/${systemCommand.name}`)
|
.map((systemCommand) => `/${systemCommand.name}`)
|
||||||
.join(', ')}`
|
.join(', ')}`
|
||||||
);
|
);
|
||||||
@@ -79,7 +80,7 @@ const rest: REST = new REST({ version: '10' }).setToken(process.env.DISCORD_BOT_
|
|||||||
logger.debug(`Refreshing system slash command for guild id '${systemGuildId}'.`);
|
logger.debug(`Refreshing system slash command for guild id '${systemGuildId}'.`);
|
||||||
refreshCommands(
|
refreshCommands(
|
||||||
Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID!, systemGuildId),
|
Routes.applicationGuildCommands(process.env.DISCORD_APPLICATION_ID!, systemGuildId),
|
||||||
systemCommands
|
systemSlashCommands
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user