Files
SupportBot/commands/announce.js
T

70 lines
2.8 KiB
JavaScript
Raw Normal View History

2020-12-11 21:38:31 +00:00
// SupportBot Created by Emerald Services
// Announce User
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
if (supportbot.DeleteMessages == "true") message.delete();
2020-06-15 23:58:37 +01:00
let locateChannel = message.guild.channels.cache.find(AnnouncementChannel => AnnouncementChannel.name === supportbot.AnnouncementChannel);
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 });
2020-07-15 02:16:15 +01:00
let Admins = message.guild.roles.cache.find(adminRole => adminRole.name === 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));
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
};