mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: link command basic functionaility
This commit is contained in:
1 parent
97d427a6a8
commit
19298b9ad6
19 files changed
+225
-166
No files matched your search
@@ -1,40 +0,0 @@
|
||||
import { EmbedBuilder, TextChannel } from 'discord.js';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import { NEGATIVE_COLOR } from '../constants/colors';
|
||||
import { client } from '../core/discord/client';
|
||||
import isDev from '../core/node/isDev';
|
||||
|
||||
const PROCESS_ERROR_EVENTS = ['uncaughtException'];
|
||||
const CLIENT_ERROR_EVENTS = ['error'];
|
||||
|
||||
export function handleError(error: Error, command: string) {
|
||||
console.error(error);
|
||||
|
||||
(
|
||||
client.guilds.cache
|
||||
.get(discord.tres_guild_id)
|
||||
?.channels.cache.get(discord.tres_log_channel) as TextChannel
|
||||
).send({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setTitle(`${client.user?.username} ran into an error`)
|
||||
.setColor(NEGATIVE_COLOR)
|
||||
.setDescription(
|
||||
`\`\`\`${[command, error.name, error.message, error.stack]
|
||||
.filter((item) => item !== undefined)
|
||||
.join('\n\n')}\`\`\``,
|
||||
),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
export function registerErrorHandlers() {
|
||||
if (!isDev()) {
|
||||
PROCESS_ERROR_EVENTS.forEach((name) =>
|
||||
process.on(name, (error) => handleError(error, 'process error')),
|
||||
);
|
||||
CLIENT_ERROR_EVENTS.forEach((name) =>
|
||||
client.on(name, (error) => handleError(error, 'client error')),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import embedNegative from '../../../core/discord/embedNegative';
|
||||
import embedWarning from '../../../core/discord/embedWarning';
|
||||
import normalizeInteractionReturnable from '../../../core/discord/normalizeInteractionReturnable';
|
||||
import { psa } from '../../../core/discord/psa';
|
||||
import { handleError } from '../../error';
|
||||
|
||||
export default async function handleChatInputCommand(
|
||||
interaction: ChatInputCommandInteraction<CacheType>,
|
||||
@@ -55,6 +54,8 @@ export default async function handleChatInputCommand(
|
||||
.setStyle(ButtonStyle.Link),
|
||||
);
|
||||
|
||||
console.error(interaction.commandName, error);
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
embedNegative(
|
||||
@@ -64,7 +65,5 @@ export default async function handleChatInputCommand(
|
||||
],
|
||||
components: [actionRow],
|
||||
});
|
||||
|
||||
handleError(error as Error, interaction.commandName);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import { searchPlayersCommand } from '../../commands/searchPlayers';
|
||||
import { searchTanksCommand } from '../../commands/searchTanks';
|
||||
import { statsCommand } from '../../commands/stats';
|
||||
import { todayCommand } from '../../commands/today';
|
||||
import { verifyCommand } from '../../commands/verify';
|
||||
import { verifyCommand } from '../../commands/link';
|
||||
import getClientId from '../../core/node/getClientId';
|
||||
import isDev from '../../core/node/isDev';
|
||||
import { secrets } from '../../core/node/secrets';
|
||||
|
||||
Reference in new issue
Block a user