30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
const pool = global.pool
|
|
const fpbx = global.fpbx
|
|
const client = global.client
|
|
const log = global.log
|
|
|
|
module.exports = {};
|
|
|
|
module.exports.execute = async (interaction) => {
|
|
const [lookup] = await pool.query('SELECT * FROM discord_users WHERE discordId = ?', [interaction.user.id]);
|
|
if (!lookup) {
|
|
await interaction.reply({ content: `We're sorry, It doesn't look like you have an extension!`, ephemeral: true });
|
|
return;
|
|
}
|
|
if (interaction.options.getBoolean("confirm") !== true) {
|
|
await interaction.reply({ content: `You must confirm you want to delete your extension!`, ephemeral: true });
|
|
return;
|
|
}
|
|
fpbx.deleteExtension(lookup.extension).then(async (res) => {
|
|
if (res[0].deleteExtension.status != true) {
|
|
await interaction.reply({ content: `Something went wrong :(`, ephemeral: true });
|
|
return;
|
|
}
|
|
await pool.query('DELETE FROM discord_users WHERE discordId = ?', [interaction.user.id]);
|
|
await fpbx.reload();
|
|
await interaction.reply({ content: `Extension ${lookup.extension} deleted!`, ephemeral: true });
|
|
}).catch(async (error) => {
|
|
log.error(error);
|
|
await interaction.reply({ content: 'There was an error while deleting your extension!', ephemeral: true });
|
|
});
|
|
} |