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");
|
2022-08-12 01:35:36 +01:00
|
|
|
|
2021-10-27 19:30:10 -05:00
|
|
|
const supportbot = yaml.load(
|
|
|
|
|
fs.readFileSync("./Configs/supportbot.yml", "utf8")
|
|
|
|
|
);
|
2022-08-12 01:35:36 +01:00
|
|
|
|
|
|
|
|
const cmdconfig = yaml.load(
|
|
|
|
|
fs.readFileSync("./Configs/commands.yml", "utf8")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const msgconfig = yaml.load(
|
|
|
|
|
fs.readFileSync("./Configs/messages.yml", "utf8")
|
|
|
|
|
);
|
2021-10-25 23:18:28 +01:00
|
|
|
|
|
|
|
|
const Command = require("../Structures/Command.js");
|
2022-08-11 19:19:29 +01:00
|
|
|
const { channel } = require("diagnostics_channel");
|
2021-10-25 23:18:28 +01:00
|
|
|
|
|
|
|
|
module.exports = new Command({
|
2022-07-23 07:50:12 +01:00
|
|
|
name: cmdconfig.Suggestion.Command,
|
|
|
|
|
description: cmdconfig.Suggestion.Description,
|
2022-07-22 13:19:05 +01:00
|
|
|
type: Discord.ApplicationCommandType.ChatInput,
|
2021-12-18 18:57:26 -06:00
|
|
|
options: [
|
2021-10-25 23:18:28 +01:00
|
|
|
{
|
2021-10-27 19:20:10 -05:00
|
|
|
name: "suggestion",
|
|
|
|
|
description: "Create a Suggestion",
|
2022-07-22 13:19:05 +01:00
|
|
|
type: Discord.ApplicationCommandOptionType.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
|
|
|
],
|
2022-07-23 07:50:12 +01:00
|
|
|
permissions: cmdconfig.Suggestion.Permission,
|
2021-10-25 23:18:28 +01:00
|
|
|
|
|
|
|
|
async run(interaction) {
|
2022-07-23 07:50:12 +01:00
|
|
|
let disableCommand = true;
|
|
|
|
|
|
2022-01-30 00:07:04 -06:00
|
|
|
const { getChannel } = interaction.client;
|
2022-08-11 19:19:29 +01:00
|
|
|
|
2021-12-15 00:19:40 -06:00
|
|
|
const suggestChannel = await getChannel(
|
2022-08-12 01:35:36 +01:00
|
|
|
supportbot.Suggestions.Channel,
|
2021-12-15 00:19:40 -06:00
|
|
|
interaction.guild
|
2021-11-21 18:42:18 -06:00
|
|
|
);
|
2021-10-25 23:18:28 +01:00
|
|
|
|
2022-07-22 13:19:05 +01:00
|
|
|
const NoChannel = new Discord.EmbedBuilder()
|
2021-10-25 23:18:28 +01:00
|
|
|
.setTitle("Missing Channel!")
|
2022-08-12 01:35:36 +01:00
|
|
|
.setDescription(msgconfig.Error.InvalidChannel)
|
|
|
|
|
.setColor(supportbot.Embed.Colours.Error);
|
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
|
|
|
|
2022-07-22 13:19:05 +01:00
|
|
|
const SuggestEmbed = new Discord.EmbedBuilder()
|
2022-08-11 19:19:29 +01:00
|
|
|
.addFields(
|
|
|
|
|
{ name: "Suggestion", value: suggestion, inline: true},
|
|
|
|
|
{ name: "From", value: `<@${interaction.user.id}>`},
|
|
|
|
|
)
|
|
|
|
|
|
2021-10-27 19:20:10 -05:00
|
|
|
.setThumbnail(interaction.user.displayAvatarURL())
|
2022-02-25 21:55:33 -06:00
|
|
|
.setFooter({
|
2022-08-12 01:35:36 +01:00
|
|
|
text: supportbot.Embed.Footer,
|
2022-02-25 21:55:33 -06:00
|
|
|
iconURL: interaction.user.displayAvatarURL(),
|
|
|
|
|
})
|
2022-08-12 01:35:36 +01:00
|
|
|
.setColor(supportbot.Embed.Colours.General);
|
2021-10-25 23:18:28 +01:00
|
|
|
|
2021-10-28 19:08:06 -05:00
|
|
|
const suggestionMsg = await suggestChannel.send({ embeds: [SuggestEmbed] });
|
2022-08-11 19:19:29 +01:00
|
|
|
|
2022-08-12 01:35:36 +01:00
|
|
|
if (supportbot.Suggestions.UpvoteEmoji && supportbot.Suggestions.DownvoteEmoji) {
|
|
|
|
|
await suggestionMsg.react(supportbot.Suggestions.UpvoteEmoji);
|
|
|
|
|
await suggestionMsg.react(supportbot.Suggestions.DownvoteEmoji);
|
2022-06-21 01:38:22 +01:00
|
|
|
|
2022-08-12 01:35:36 +01:00
|
|
|
if (supportbot.Suggestions.Threads.Enabled) {
|
2022-06-21 01:38:22 +01:00
|
|
|
await suggestionMsg.startThread({
|
2022-08-12 01:35:36 +01:00
|
|
|
name: supportbot.Suggestions.Threads.Title,
|
2022-06-21 01:38:22 +01:00
|
|
|
autoArchiveDuration: 60,
|
2022-08-11 19:19:29 +01:00
|
|
|
type: Discord.ChannelType.GuildPublicThread,
|
2022-08-12 01:35:36 +01:00
|
|
|
reason: supportbot.Suggestions.Threads.Reason,
|
2022-06-21 01:38:22 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
2021-10-28 19:08:06 -05:00
|
|
|
}
|
2021-10-25 23:18:28 +01:00
|
|
|
|
2022-07-22 13:19:05 +01:00
|
|
|
const Submitted = new Discord.EmbedBuilder()
|
2021-10-25 23:18:28 +01:00
|
|
|
.setTitle("Suggestion Submitted!")
|
2022-08-11 19:19:29 +01:00
|
|
|
.setDescription(`:white_check_mark: You have successfully submitted a suggestion.`)
|
|
|
|
|
.addFields(
|
|
|
|
|
{ name: "Sent to:", value: `<#${suggestChannel.id}>`},
|
2021-10-27 19:20:10 -05:00
|
|
|
)
|
2022-08-12 01:35:36 +01:00
|
|
|
.setColor(supportbot.Embed.Colours.Success);
|
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
|
|
|
},
|
|
|
|
|
});
|