Files
SupportBot/commands/suggest.js
T

62 lines
2.5 KiB
JavaScript
Raw Normal View History

2020-12-18 13:37:56 +00:00
// SupportBot, Created by Emerald Services
2020-06-15 23:58:37 +01:00
// 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,
2020-07-14 19:42:46 +01:00
description: supportbot.SuggestionDesc,
2020-06-15 23:58:37 +01:00
execute(message, args) {
2020-07-27 10:43:11 -04:00
if (supportbot.DeleteMessages == "true") message.delete();
2020-06-15 23:58:37 +01:00
let locateChannel = message.guild.channels.cache.find(SuggestionChannel => SuggestionChannel.name === supportbot.SuggestionChannel);
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.SuggestCommand}!`);
2020-06-15 23:58:37 +01:00
const errornochannel = new Discord.MessageEmbed()
2020-07-14 19:42:46 +01:00
.setTitle("Invalid Channel")
.setDescription(`${supportbot.InvalidChannel}\n\nChannel Required: \`${supportbot.SuggestionChannel}\``)
2020-06-15 23:58:37 +01:00
.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
}
2020-07-27 10:43:11 -04:00
};