Improved error handling?
This commit is contained in:
parent
c0cba3e14e
commit
25859d364d
@ -53,7 +53,7 @@
|
|||||||
"supportServer": "https://discord.gg/g5JRGn7PxU"
|
"supportServer": "https://discord.gg/g5JRGn7PxU"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"noGuild": "Setup has not been completed yet. Try running </setup:1065407649363005561> or </help setup:1065346941166297129>",
|
"noGuild": "I was unable to find an entry for your server in the database. Try using the `/setup rolemenu` or `/relay` commands to generate a new entry. If that fails, try `/setup reset`, then kick me and re-add me. If you continue receiving this error, join the Support Server or DM @vfsh",
|
||||||
"invalidSubcommand": "Invalid subcommand detected.",
|
"invalidSubcommand": "Invalid subcommand detected.",
|
||||||
"noTreeMessage": "</tree:0> - Make sure you've sent or refreshed a Tree recently.",
|
"noTreeMessage": "</tree:0> - Make sure you've sent or refreshed a Tree recently.",
|
||||||
"noLeaderboardMessage": "</top trees:0> - Make sure you've sent or refreshed the Tallest Trees leaderboard recently.",
|
"noLeaderboardMessage": "</top trees:0> - Make sure you've sent or refreshed the Tallest Trees leaderboard recently.",
|
||||||
|
85
main.js
85
main.js
@ -47,47 +47,58 @@ client.once('ready', async () => {
|
|||||||
|
|
||||||
// slash-commands
|
// slash-commands
|
||||||
client.on('interactionCreate', async interaction => {
|
client.on('interactionCreate', async interaction => {
|
||||||
if (interaction.isCommand()) {
|
try {
|
||||||
if (isDev) {
|
if (interaction.isCommand()) {
|
||||||
// console.log(interaction);
|
if (isDev) {
|
||||||
|
// console.log(interaction);
|
||||||
|
}
|
||||||
|
const { commandName } = interaction;
|
||||||
|
|
||||||
|
if (client.slashCommands.has(commandName)) {
|
||||||
|
client.slashCommands.get(commandName).execute(interaction);
|
||||||
|
} else {
|
||||||
|
interaction.reply('Sorry, I don\'t have access to that command.');
|
||||||
|
console.error('Slash command attempted to run but not found: ' + commandName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const { commandName } = interaction;
|
|
||||||
|
if (interaction.isButton()) {
|
||||||
if (client.slashCommands.has(commandName)) {
|
switch (interaction.component.customId) {
|
||||||
client.slashCommands.get(commandName).execute(interaction);
|
case 'refresh':
|
||||||
} else {
|
// console.log(JSON.stringify(interaction));
|
||||||
interaction.reply('Sorry, I don\'t have access to that command.');
|
await fn.refresh(interaction).catch(err => {
|
||||||
console.error('Slash command attempted to run but not found: ' + commandName);
|
interaction.channel.send(fn.builders.errorEmbed("Oops! Something went wrong!"));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (interaction.isButton()) {
|
|
||||||
switch (interaction.component.customId) {
|
|
||||||
case 'refresh':
|
|
||||||
// console.log(JSON.stringify(interaction));
|
|
||||||
await fn.refresh(interaction).catch(err => {
|
|
||||||
interaction.channel.send(fn.builders.errorEmbed(err));
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'deleteping':
|
|
||||||
if (interaction.message.deletable) {
|
|
||||||
await interaction.message.delete().catch(err => {
|
|
||||||
// console.error(err);
|
|
||||||
});
|
});
|
||||||
}
|
break;
|
||||||
break;
|
case 'deleteping':
|
||||||
case 'waterpingrole':
|
if (interaction.message.deletable) {
|
||||||
const waterPingStatus = await fn.buttonHandlers.waterPing(interaction);
|
await interaction.message.delete().catch(err => {
|
||||||
await interaction.reply(waterPingStatus).catch(e => console.error(e));
|
// console.error(err);
|
||||||
break;
|
});
|
||||||
case 'fruitpingrole':
|
}
|
||||||
const fruitPingStatus = await fn.buttonHandlers.fruitPing(interaction);
|
break;
|
||||||
await interaction.reply(fruitPingStatus).catch(e => console.error(e));
|
case 'waterpingrole':
|
||||||
break;
|
const waterPingStatus = await fn.buttonHandlers.waterPing(interaction);
|
||||||
default:
|
await interaction.reply(waterPingStatus).catch(e => console.error(e));
|
||||||
break;
|
break;
|
||||||
|
case 'fruitpingrole':
|
||||||
|
const fruitPingStatus = await fn.buttonHandlers.fruitPing(interaction);
|
||||||
|
await interaction.reply(fruitPingStatus).catch(e => console.error(e));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(err) {
|
||||||
|
if (err === "Guild doesn't exist in database!") {
|
||||||
|
interaction.channel.send(fn.builders.errorEmbed(strings.error.noGuild));
|
||||||
|
console.error(err);
|
||||||
|
} else {
|
||||||
|
interaction.channel.send("Oops! An error occurred... Sorry about that, please contact my owner @vfsh if this keeps happening.");
|
||||||
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageUpdate', async (oldMessage, message) => {
|
client.on('messageUpdate', async (oldMessage, message) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user