From 2f59ff414770c98ba04e88c7b907c4174f412f81 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sat, 25 Jan 2025 12:27:13 -0700 Subject: [PATCH 1/2] Add paging stuff --- commands.js | 35 ++++++++++++++++++++++++++ interactionHandlers/commands/paging.js | 27 ++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 interactionHandlers/commands/paging.js diff --git a/commands.js b/commands.js index 3cfd34a..895b1a5 100644 --- a/commands.js +++ b/commands.js @@ -22,6 +22,41 @@ module.exports = [ } ] }, + { + "name": "paging", + "description": "Subcommands for managing your paging groups", + "type": 1, + "options": [ + { + "name": "add", + "description": "Add yourself to a paging group", + "type": 1, + "options": [ + { + "name": "group", + "description": "Page group to join", + "type": 3, + "required": true, + "choices": require("./pageGroups.json") + } + ] + }, + { + "name": "remove", + "description": "Remove yourself from a paging group", + "type": 1, + "options": [ + { + "name": "group", + "description": "Page group to leave", + "type": 3, + "required": true, + "choices": require("./pageGroups.json") + } + ] + } + ] + }, { "name": "list", "description": "List all extensions on the LiteNet Phone System", diff --git a/interactionHandlers/commands/paging.js b/interactionHandlers/commands/paging.js new file mode 100644 index 0000000..6502f12 --- /dev/null +++ b/interactionHandlers/commands/paging.js @@ -0,0 +1,27 @@ +const pool = global.pool +const fpbx = global.fpbx +const client = global.client +const log = global.log + +module.exports = {}; + +module.exports.execute = async (interaction) => { + const subcommand = interaction.options.getSubcommand(); + 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; + } + const pageGroup = await interaction.options.getString('group'); + switch (subcommand) { + case 'add': + fpbx.joinPageGroup(lookup.extension, pageGroup).then(async (res) => { + if (res == true) { + await interaction.reply({ content: `Added!`, ephemeral: true }); + } else { + await interaction.reply({ content: `Something went wrong (Or you're already in that page group!)`, ephemeral: true }); + } + }); + break; + } +} \ No newline at end of file From b61e48c5354a08bb4b57e00de3b9193dd244ef00 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sat, 25 Jan 2025 12:27:35 -0700 Subject: [PATCH 2/2] More page stuff --- interactionHandlers/commands/paging.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/interactionHandlers/commands/paging.js b/interactionHandlers/commands/paging.js index 6502f12..d548275 100644 --- a/interactionHandlers/commands/paging.js +++ b/interactionHandlers/commands/paging.js @@ -23,5 +23,14 @@ module.exports.execute = async (interaction) => { } }); break; + case "remove": + fpbx.leavePageGroup(lookup.extension, pageGroup).then(async (res) => { + if (res == true) { + await interaction.reply({ content: `Removed!`, ephemeral: true }); + } else { + await interaction.reply({ content: `Something went wrong (Or you're not in that page group!)`, ephemeral: true }); + } + }); + break; } } \ No newline at end of file