Files
SupportBot/commands/announce.js
T

73 lines
3.2 KiB
JavaScript
Raw Normal View History

2020-12-18 13:37:56 +00:00
// SupportBot, Created by Emerald Services
// Announce
2019-07-24 16:52:30 -06:00
const Discord = require("discord.js");
2020-06-15 23:58:37 +01:00
const fs = require("fs");
2020-01-26 22:35:45 +00:00
2020-01-25 16:59:35 +00:00
const yaml = require('js-yaml');
2020-06-15 23:58:37 +01:00
const { execute } = require("./help");
2020-01-25 16:59:35 +00:00
const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
2019-07-24 16:52:30 -06:00
2020-06-15 23:58:37 +01:00
module.exports = {
name: supportbot.AnnounceCommand,
2020-07-14 19:42:46 +01:00
description: supportbot.AnnounceDesc,
2020-06-15 23:58:37 +01:00
execute(message, args) {
2020-07-27 10:44:06 -04:00
2021-05-23 10:39:03 +02:00
if (supportbot.DeleteMessages) message.delete();
2020-07-27 10:44:06 -04:00
2021-05-23 10:39:03 +02:00
let locateChannel = message.guild.channels.cache.find(AnnouncementChannel => AnnouncementChannel.name === supportbot.AnnouncementChannel) || message.guild.channels.cache.find(AnnouncementChannel => AnnouncementChannel.id === supportbot.AnnouncementChannel)
2020-06-15 23:58:37 +01:00
2021-02-02 17:01:58 +00:00
console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.AnnounceCommand}!`);
2020-06-15 23:58:37 +01:00
const errornochannel = new Discord.MessageEmbed()
2020-07-11 13:17:57 +01:00
.setTitle("Invalid Channel")
2020-07-14 19:42:46 +01:00
.setDescription(`${supportbot.InvalidChannel}\n\nChannel Required: \`${supportbot.AnnouncementChannel}`)
2020-06-15 23:58:37 +01:00
.setColor(supportbot.ErrorColour);
if(!locateChannel) return message.channel.send({ embed: errornochannel });
2021-05-23 10:39:03 +02:00
let Admins = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Admin) || message.guild.roles.cache.find(adminRole => adminRole.id === supportbot.Admin)
2020-06-15 23:58:37 +01:00
2020-07-11 13:17:57 +01:00
const NoPerms = new Discord.MessageEmbed()
.setTitle("Invalid Permissions!")
2020-07-15 02:16:15 +01:00
.setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${Admins.name}\``)
2020-07-11 13:17:57 +01:00
.setColor(supportbot.WarningColour)
2020-07-14 19:42:46 +01:00
2020-07-15 02:16:15 +01:00
if (!message.member.roles.cache.has(Admins.id))
2020-07-14 19:42:46 +01:00
return message.channel.send({ embed: NoPerms });
2020-06-15 23:58:37 +01:00
const embed = new Discord.MessageEmbed()
.setDescription(`> **${supportbot.AnnouncementStarter}**`)
.setColor(supportbot.EmbedColour)
message.channel.send({ embed: embed });
let announcement = []
message.channel.awaitMessages(response => response.content.length > 2, {
max: 1,
time: 500000,
errors: ['time'],
}).then((collected) => {
announcement.push(collected.map(r => r.content));
2021-02-02 17:01:58 +00:00
locateChannel.send('@everyone')
2020-06-15 23:58:37 +01:00
const AnnouncementEmbed = new Discord.MessageEmbed()
.setTitle(supportbot.AnnouncementTitle)
.setThumbnail(supportbot.AnnouncementIcon)
.setDescription(announcement)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL());
locateChannel.send({ embed: AnnouncementEmbed }).then(async function(msg) {
const AnnouncementComplete = new Discord.MessageEmbed()
.setColor(supportbot.SuccessColour)
.setDescription(`:white_check_mark: You have successfully created an announcement. <#${locateChannel.id}>`)
message.channel.send({ embed: AnnouncementComplete })
})
});
2019-07-24 16:52:30 -06:00
2020-06-15 23:58:37 +01:00
}
2020-01-25 13:37:25 +00:00
2020-07-27 10:44:06 -04:00
};