From 31f6b9e08e9d70f97d02ec100163ecaa54e56ac8 Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 28 Oct 2021 19:08:06 -0500 Subject: [PATCH] Fix suggestions --- Commands/suggest.js | 20 +++++++++++----- Configs/supportbot.yml | 2 ++ Events/messageReactionAdd.js | 45 ------------------------------------ 3 files changed, 16 insertions(+), 51 deletions(-) delete mode 100644 Events/messageReactionAdd.js diff --git a/Commands/suggest.js b/Commands/suggest.js index 52ebf16..99a99bc 100644 --- a/Commands/suggest.js +++ b/Commands/suggest.js @@ -25,14 +25,18 @@ module.exports = new Command({ permission: "SEND_MESSAGES", async run(interaction) { - const suggestChannel = client.channels.cache.get( - supportbot.SuggestionChannel - ); + const suggestChannel = + interaction.guild.channels.cache.find( + (channel) => channel.name === supportbot.SuggestionChannel + ) || + interaction.guild.channels.cache.find( + (channel) => channel.id === supportbot.SuggestionChannel + ); const NoChannel = new Discord.MessageEmbed() .setTitle("Missing Channel!") .setDescription(`${supportbot.InvalidChannel}`) - .setColor(supportbot.WarningColour); + .setColor(supportbot.ErrorColour); if (!suggestChannel) return interaction.reply({ embeds: [NoChannel] }); @@ -45,7 +49,11 @@ module.exports = new Command({ .setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL()) .setColor(supportbot.EmbedColour); - suggestChannel.reply({ embeds: [SuggestEmbed] }); + const suggestionMsg = await suggestChannel.send({ embeds: [SuggestEmbed] }); + if (supportbot.SuggestionUpvote && supportbot.SuggestionDownvote) { + suggestionMsg.react(supportbot.SuggestionUpvote); + suggestionMsg.react(supportbot.SuggestionDownvote); + } const Submitted = new Discord.MessageEmbed() .setTitle("Suggestion Submitted!") @@ -53,7 +61,7 @@ module.exports = new Command({ `:white_check_mark: You have successfully submitted a suggestion.` ) .addField("Sent to:", `<#${suggestChannel.id}>`) - .setColor(supportbot.WarningColour); + .setColor(supportbot.SuccessColour); return interaction.reply({ embeds: [Submitted] }); }, diff --git a/Configs/supportbot.yml b/Configs/supportbot.yml index 1a809a3..55b4355 100644 --- a/Configs/supportbot.yml +++ b/Configs/supportbot.yml @@ -78,6 +78,8 @@ TicketBlackListRole: "Blacklisted" # ---------------------------- SuggestionChannel: "suggestions" +SuggestionUpvote: "✅" +SuggestionDownvote: "❌" # ------------------------- # Tickets Configuration diff --git a/Events/messageReactionAdd.js b/Events/messageReactionAdd.js deleted file mode 100644 index 9f6f66b..0000000 --- a/Events/messageReactionAdd.js +++ /dev/null @@ -1,45 +0,0 @@ -// SupportBot | Emerald Services -// Ready Event - -const fs = require("fs"); - -const Discord = require("discord.js"); -const yaml = require("js-yaml"); -const supportbot = yaml.load( - fs.readFileSync("./Configs/supportbot.yml", "utf8") -); -const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); -const panelconfig = yaml.load( - fs.readFileSync("./Configs/ticket-panel.yml", "utf8") -); - -const Event = require("../Structures/Event.js"); - -module.exports = new Event("messageReactionAdd", async (client) => { - let message = { - guild: reaction.message.channel.guild, - author: user, - content: "N/A", - channel: reaction.message.channel, - }; - - if (panelconfig.TicketPanel) { - if (reaction.message.id === panelconfig.TicketPanelID) { - if ( - reaction.emoji.name == panelconfig.ButtonEmoji || - reaction.emoji.id == panelconfig.ButtonEmoji - ) { - await reaction.users.remove(user.id); - - try { - const cmd = client.commands.get(cmdconfig.OpenTicket); - if (!cmd) return; - - cmd.run(message, message.content); - } catch (error) { - console.error(error); - } - } - } - } -});