mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-10 08:18:12 +03:00
fix: bot crashing and no logs
This commit is contained in:
@@ -26,34 +26,29 @@ export async function handleIsCommand(
|
||||
throw new Error(`A command was requested that does not exist.`);
|
||||
}
|
||||
|
||||
if (command) {
|
||||
await interaction.deferReply();
|
||||
await interaction.deferReply();
|
||||
|
||||
logger.verbose(`Running ${command.info.name} interaction.`);
|
||||
try {
|
||||
const response = await command.exec(interaction, requestingUser);
|
||||
logger.verbose(`Running ${command.info.name} interaction.`);
|
||||
try {
|
||||
const response = await command.exec(interaction, requestingUser);
|
||||
|
||||
const method = interaction.replied ? "followUp" : "reply";
|
||||
|
||||
if (response instanceof MessageEmbed) {
|
||||
await interaction[method]({ embeds: [response] });
|
||||
} else if (response !== null) {
|
||||
await interaction[method](response);
|
||||
} else {
|
||||
await interaction.reply({
|
||||
content: "Done!",
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(`An error occured while executing a command.`, { command, err });
|
||||
|
||||
const method = interaction.replied ? "followUp" : "reply";
|
||||
|
||||
interaction[method](
|
||||
"An error has occured while executing this command. This has been reported."
|
||||
);
|
||||
// eslint-disable-next-line cadence/no-instanceof
|
||||
if (response instanceof MessageEmbed) {
|
||||
await interaction.editReply({ embeds: [response] });
|
||||
} else if (response !== null) {
|
||||
await interaction.editReply(response);
|
||||
} else {
|
||||
await interaction.reply({
|
||||
content: "Done!",
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(`An error occured while executing a command.`, { command, err });
|
||||
|
||||
void interaction.editReply(
|
||||
"An error has occured while executing this command. This has been reported."
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error("Failed to handle isCommand interaction", { error: e });
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { LoggerLayers } from "../data/data";
|
||||
import type { MeiLogger } from "mei-logger";
|
||||
import type { SeqLogLevel } from "seq-logging";
|
||||
|
||||
const logger = CreateLogger(`tachi-bot`, undefined, []);
|
||||
const transports: Array<any> = [];
|
||||
|
||||
if (BotConfig.LOGGER?.SEQ_API_KEY && ProcessEnv.seqUrl) {
|
||||
// Turns winston log levels into seq format.
|
||||
@@ -23,7 +23,7 @@ if (BotConfig.LOGGER?.SEQ_API_KEY && ProcessEnv.seqUrl) {
|
||||
debug: "Debug",
|
||||
};
|
||||
|
||||
logger.transports.push(
|
||||
transports.push(
|
||||
new SeqTransport({
|
||||
apiKey: BotConfig.LOGGER.SEQ_API_KEY,
|
||||
serverUrl: ProcessEnv.seqUrl,
|
||||
@@ -38,6 +38,8 @@ if (BotConfig.LOGGER?.SEQ_API_KEY && ProcessEnv.seqUrl) {
|
||||
);
|
||||
}
|
||||
|
||||
const logger = CreateLogger(`tachi-bot`, undefined, transports);
|
||||
|
||||
export default logger;
|
||||
|
||||
export function CreateLayeredLogger(layerName: LoggerLayers) {
|
||||
|
||||
Reference in New Issue
Block a user