2020-06-15 23:58:37 +01:00
// SupportBot 6.0, Created by Emerald Services
// Links Command
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 ,
execute ( message , args ) {
let locateChannel = message . guild . channels . cache . find ( AnnouncementChannel => AnnouncementChannel . name === supportbot . AnnouncementChannel );
const errornochannel = new Discord . MessageEmbed ()
. setTitle ( "SupportBot Error!" )
. setDescription ( `:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \` ${ supportbot . AnnouncementChannel } \`\n\nError Code: \`SB-03\`` )
. setColor ( supportbot . ErrorColour );
if ( ! locateChannel ) return message . channel . send ({ embed : errornochannel });
let serverAdmins = message . guild . roles . cache . find ( adminRole => adminRole . name === supportbot . Admin );
const rolerequired = new Discord . MessageEmbed ()
. setTitle ( "SupportBot Error!" )
. setDescription ( `:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \` ${ supportbot . Admin } \`\n\nError Code: \`SB-02\`` )
. setColor ( supportbot . ErrorColour );
if ( ! message . member . roles . cache . has ( serverAdmins . id )) return message . reply ({ embed : rolerequired });
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-06-15 23:58:37 +01:00
};