2020-06-15 23:58:37 +01:00
// SupportBot 6.0, Created by Emerald Services
// Suggest Command
2019-06-09 23:52:41 +01:00
const Discord = require ( "discord.js" );
2020-01-26 22:35:45 +00:00
const fs = require ( "fs" );
2020-06-15 23:58:37 +01:00
const yaml = require ( 'js-yaml' );
2020-01-26 22:35:45 +00:00
const supportbot = yaml . load ( fs . readFileSync ( './supportbot-config.yml' , 'utf8' ));
2019-06-09 23:52:41 +01:00
2020-06-15 23:58:37 +01:00
module . exports = {
name : supportbot . SuggestCommand ,
execute ( message , args ) {
let locateChannel = message . guild . channels . cache . find ( SuggestionChannel => SuggestionChannel . name === supportbot . SuggestionChannel );
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 . SuggestionChannel } \`\n\nError Code: \`SB-03\`` )
. setColor ( supportbot . ErrorColour );
if ( ! locateChannel ) return message . channel . send ({ embed : errornochannel });
const embed = new Discord . MessageEmbed ()
. setDescription ( `> ** ${ supportbot . SuggestionStarter } **` )
. setColor ( supportbot . EmbedColour )
message . channel . send ({ embed : embed });
let suggestion = []
message . channel . awaitMessages ( response => response . content . length > 2 , {
max : 1 ,
time : 500000 ,
errors : [ 'time' ],
}). then (( collected ) => {
suggestion . push ( collected . map ( r => r . content ));
const SuggestionMessage = new Discord . MessageEmbed ()
. setColor ( supportbot . EmbedColour )
. setFooter ( supportbot . EmbedFooter )
. setTitle ( supportbot . SuggestionTitle )
. setDescription ( `\`\`\` ${ suggestion } \`\`\`` )
. addFields ( { name : "From" , value : `<@ ${ message . author . id } >` , inline : false }, )
locateChannel . send ({ embed : SuggestionMessage }). then ( async function ( msg ) {
msg . react ( supportbot . SuggestReact_1 ). then (() => msg . react ( supportbot . SuggestReact_2 ));
});
const SuggestionComplete = new Discord . MessageEmbed ()
. setColor ( supportbot . SuccessColour )
. setDescription ( `:white_check_mark: Your suggestion has been successfully created. <# ${ locateChannel . id } >` )
message . channel . send ({ embed : SuggestionComplete })
});
2020-01-26 22:35:45 +00:00
2020-06-15 23:58:37 +01:00
}
};