From 9c9aa113e4f106c3994fb0ca38efbf32ebd4385d Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 24 May 2023 20:35:14 -0600 Subject: [PATCH] Add multiple message sending --- commands.json | 10 +++++++++- index.js | 34 ++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/commands.json b/commands.json index 87bb4cd..aaf0cad 100644 --- a/commands.json +++ b/commands.json @@ -3,6 +3,14 @@ "name": "send", "description": "Send a message with it's ID for the config file!", "type": 1, - "default_member_permissions": 0 + "default_member_permissions": 0, + "options": [ + { + "name": "count", + "description": "Number of messages to send", + "type": 4, + "required": true + } + ] } ] \ No newline at end of file diff --git a/index.js b/index.js index 635caba..2dbc720 100644 --- a/index.js +++ b/index.js @@ -331,21 +331,31 @@ client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; switch (interaction.commandName) { case "send": // Send a message with it's message ID - interaction.channel.send({ - embeds: [{ - description: "Please Wait" - }] - }).then(async (msg) => { - await msg.edit({ + // check if integer 'count' exists, if not, set it to 1 + if (!interaction.options.getInteger('count')) { + count = 1; + } else { + count = interaction.options.getInteger('count'); + } + + // Send a message `count` fimes + for (i = 0; i < count; i++) { + interaction.channel.send({ embeds: [{ - description: `ID: ${msg.id}` + description: "Please Wait" }] + }).then(async (msg) => { + await msg.edit({ + embeds: [{ + description: `ID: ${msg.id}` + }] + }); + interaction.reply({ + "ephemeral": true, + content: "Done!" + }) }); - interaction.reply({ - "ephemeral": true, - content: "Done!" - }) - }); + } break; } });