Add /send

This commit is contained in:
Ecolipsy 2021-12-02 20:55:11 +01:00
parent beff32bb38
commit 71f9be9f42

View file

@ -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!");