mirror of
https://github.com/danbulant/Shasha
synced 2026-05-24 20:31:47 +00:00
49 lines
No EOL
2 KiB
JavaScript
49 lines
No EOL
2 KiB
JavaScript
'use strict';
|
|
const commando = require("@iceprod/discord.js-commando");
|
|
const { ranLog, errLog, trySend, sentAdCheck, tryReact } = require("../../resources/functions");
|
|
|
|
module.exports = class send extends commando.Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: "send",
|
|
memberName: "send",
|
|
group: "utility",
|
|
description: "Send message to designated channel."
|
|
});
|
|
}
|
|
async run(msg, args ) {
|
|
const comarg = args.trim().split(/ +/);
|
|
const bot = this.client;
|
|
let at = comarg[0];
|
|
if (!comarg[0]) {
|
|
return trySend(this.client, msg, 'Where?!?');
|
|
}
|
|
if (comarg[0].startsWith('<#') && comarg[0].endsWith('>')) {
|
|
at = comarg[0].slice(2, -1);
|
|
}
|
|
const channel = bot.channels.cache.get(at);
|
|
const sendTheMes = args.slice(comarg[0].length).trim();
|
|
if (!channel) {
|
|
return trySend(this.client, msg, "Give me the right `channel_[mention, ID]` bruh");
|
|
}
|
|
try {
|
|
if (sendTheMes.length === 0) {
|
|
return trySend(this.client, at, `<@!${msg.author.id}> If you wanna send nothin then why you even typed that <:bruhLife:798789686242967554>`);
|
|
}
|
|
const send = await channel.send(sendTheMes);
|
|
sentAdCheck(send);
|
|
const filter = () => true;
|
|
const collector = send.createReactionCollector(filter, {time: 15*6*1000, dispose:true});
|
|
collector.on('collect', r => {
|
|
try {
|
|
msg.react(r.emoji);
|
|
} catch (e) {}
|
|
});
|
|
collector.on('remove', async r => await msg.reactions.resolve(r).id.remove(r.id));
|
|
tryReact(msg, 'yeLife:796401669188354090');
|
|
return ranLog(msg,'send',`ID: ${send.id} url: ${send.url}\nSent to channel: ${channel.name} (${channel.id}) of ${send.guild.name}\nContent: ${args.slice(at.length)}`);
|
|
} catch (e) {
|
|
return errLog(e, msg, this.client);
|
|
}
|
|
}
|
|
}; |