Skip to content

Commit

Permalink
Fix Critical Console Error
Browse files Browse the repository at this point in the history
  • Loading branch information
TecEash1 committed May 20, 2024
1 parent e8cb489 commit 227abce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions events/slashCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module.exports = {
try {
await command.execute(interaction);
} catch (err) {
console.error(err);
await interaction.reply({
embeds: [error],
ephemeral: true,
Expand Down
28 changes: 15 additions & 13 deletions functions/logConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ module.exports = (client) => {
const webhooks = await db.get("webhooks");
webhookUrlConsoleLogs = webhooks.console;
webhookURL = webhookUrlConsoleLogs;
let isWebhookSetupSuccessful = false;

let webhookClient;
const setupWebhookClient = async () => {
const webhooks = await db.get("webhooks");
webhookURL = webhooks.console;

try {
webhookClient = new WebhookClient({ url: webhookURL });
isWebhookSetupSuccessful = true;
} catch (error) {
console.log(
"\x1b[31m\x1b[1m%s\x1b[0m",
"CONSOLE LOGGING IN DISCORD DISABLED. SET WEBHOOK URL WITH /SETTINGS.",
);
isWebhookSetupSuccessful = false;
}
};
setupWebhookClient();
await setupWebhookClient();

webhookUpdateEvent.on("update", (newWebhookUrl) => {
webhookUpdateEvent.on("update", async (newWebhookUrl) => {
webhookURL = newWebhookUrl;
setupWebhookClient();
await setupWebhookClient();
});

function customLogger(type, ...messages) {
Expand Down Expand Up @@ -70,13 +70,15 @@ module.exports = (client) => {
}
}

webhookClient
.send({
username: "Taurus Console",
avatarURL: client.user.displayAvatarURL(),
embeds: [embed],
})
.catch(console.error);
if (isWebhookSetupSuccessful) {
webhookClient
.send({
username: "Taurus Console",
avatarURL: client.user.displayAvatarURL(),
embeds: [embed],
})
.catch(console.error);
}

console.originalLog(combinedMessage);
}
Expand Down

0 comments on commit 227abce

Please sign in to comment.