From 71f9be9f42d2a9be91aa343a8e1e23e528db0569 Mon Sep 17 00:00:00 2001 From: Ecolipsy Date: Thu, 2 Dec 2021 20:55:11 +0100 Subject: [PATCH] Add /send --- index.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 59c7db9..7240db1 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const dc = require("discord.js"); const client = new dc.Client({intents: ["GUILDS", "GUILD_MESSAGES"]}); const fs = require("fs"); +const allowed = ["831598877320413244"]; function isDir(path){ try{ @@ -68,6 +69,23 @@ client.on("ready", () => { required: true } ] + }, + { + name: "send", + description: "Sends a message in specificed channel or current channel.", + options: [ + { + name: "message", + description: "What to send?", + type: 3, + required: true + }, + { + name: "channel", + description: "Where to send?", + type: 7 + } + ] } ]); }); @@ -116,6 +134,17 @@ client.on("interactionCreate", (int) => { embed.setDescription("And the games continue, this game is currently on tie, press a button to continue."); } int.reply({embeds: [embed], components: [msgRow]}); + } else if(int.commandName == "send"){ + if(!allowed.includes(int.user.id)) return int.reply({content: "You don't have permissions to use this command.", ephemeral: true}); + var channel = int.options.getChannel("channel") || int.channel; + var message = int.options.getString("message"); + int.deferReply(); + channel.send(message).then(msg => { + int.reply({content: "Successfully sent message.", ephemeral: true}); + }).catch(e => { + int.reply({content: "An error has occured, check console."}); + console.log(e); + }); } } else if(int.isButton()){ console.log("Button detected"); @@ -171,7 +200,6 @@ function doStuff(msg, cmd){ } -const allowed = ["831598877320413244"]; client.on("messageCreate", (msg) => { if(msg.content.startsWith("rps!ev")){ if(!allowed.includes(msg.author.id)) return msg.channel.send("Nu perms!");