Files
SupportBot/Commands/suggest.js
T

67 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-10-25 23:18:28 +01:00
// SupportBot | Emerald Services
// Ping Command
const fs = require("fs");
const Discord = require("discord.js");
const yaml = require("js-yaml");
2021-10-27 19:30:10 -05:00
const supportbot = yaml.load(
fs.readFileSync("./Configs/supportbot.yml", "utf8")
);
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));
2021-10-25 23:18:28 +01:00
const Command = require("../Structures/Command.js");
module.exports = new Command({
name: cmdconfig.SuggestCommand,
description: cmdconfig.SuggestCommandDesc,
options: [
2021-10-25 23:18:28 +01:00
{
2021-10-27 19:20:10 -05:00
name: "suggestion",
description: "Create a Suggestion",
type: "STRING",
2021-12-28 19:06:35 -06:00
required: true,
2021-10-27 19:20:10 -05:00
},
2021-10-25 23:18:28 +01:00
],
permissions: ["SEND_MESSAGES"],
2021-10-25 23:18:28 +01:00
async run(interaction) {
const { getRole, getChannel, getCategory } = interaction.client;
const suggestChannel = await getChannel(
supportbot.SuggestionChannel,
interaction.guild
2021-11-21 18:42:18 -06:00
);
2021-10-25 23:18:28 +01:00
const NoChannel = new Discord.MessageEmbed()
.setTitle("Missing Channel!")
.setDescription(`${supportbot.InvalidChannel}`)
2021-10-28 19:08:06 -05:00
.setColor(supportbot.ErrorColour);
2021-10-25 23:18:28 +01:00
if (!suggestChannel) return interaction.reply({ embeds: [NoChannel] });
2021-10-27 19:20:10 -05:00
let suggestion = interaction.options.getString("suggestion");
2021-10-25 23:18:28 +01:00
const SuggestEmbed = new Discord.MessageEmbed()
2021-10-27 19:20:10 -05:00
.addField("Suggestion", suggestion, true)
.addField("From", `<@${interaction.user.id}>`)
.setThumbnail(interaction.user.displayAvatarURL())
.setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL())
.setColor(supportbot.EmbedColour);
2021-10-25 23:18:28 +01:00
2021-10-28 19:08:06 -05:00
const suggestionMsg = await suggestChannel.send({ embeds: [SuggestEmbed] });
if (supportbot.SuggestionUpvote && supportbot.SuggestionDownvote) {
suggestionMsg.react(supportbot.SuggestionUpvote);
suggestionMsg.react(supportbot.SuggestionDownvote);
}
2021-10-25 23:18:28 +01:00
const Submitted = new Discord.MessageEmbed()
.setTitle("Suggestion Submitted!")
2021-10-27 19:20:10 -05:00
.setDescription(
`:white_check_mark: You have successfully submitted a suggestion.`
)
2021-10-25 23:18:28 +01:00
.addField("Sent to:", `<#${suggestChannel.id}>`)
2021-10-28 19:08:06 -05:00
.setColor(supportbot.SuccessColour);
2021-10-25 23:18:28 +01:00
2021-10-27 19:20:10 -05:00
return interaction.reply({ embeds: [Submitted] });
2021-10-25 23:18:28 +01:00
},
});