Files
SupportBot/Commands/suggest.js
T

84 lines
2.5 KiB
JavaScript
Raw Normal View History

2021-10-25 23:18:28 +01:00
// SupportBot | Emerald Services
2022-06-21 09:54:22 +02:00
// Suggest Command
2021-10-25 23:18:28 +01:00
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) {
2022-01-30 00:07:04 -06:00
const { getChannel } = 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!")
2022-02-11 23:47:06 -06:00
.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())
2022-02-25 21:55:33 -06:00
.setFooter({
text: supportbot.EmbedFooter,
iconURL: interaction.user.displayAvatarURL(),
})
2021-10-27 19:20:10 -05:00
.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) {
2022-01-29 23:57:10 -06:00
await suggestionMsg.react(supportbot.SuggestionUpvote);
await suggestionMsg.react(supportbot.SuggestionDownvote);
2022-06-21 01:38:22 +01:00
if (supportbot.SuggestionThreads) {
await suggestionMsg.startThread({
name: `Suggestion-releated Thread`,
autoArchiveDuration: 60,
type: 'GUILD_PUBLIC_THREAD',
reason: 'Suggestion-releated thread',
})
}
2021-10-28 19:08:06 -05:00
}
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
2022-06-21 01:38:22 +01:00
return interaction.reply({
ephemeral: true,
embeds: [Submitted]
})
2021-10-25 23:18:28 +01:00
},
});