From 62e7e33406769a048f01a2a15e6e4453693f8e27 Mon Sep 17 00:00:00 2001 From: Xiled Emerald Date: Mon, 25 Oct 2021 00:13:27 +0100 Subject: [PATCH 01/26] Update Client.js --- Structures/Client.js | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/Structures/Client.js b/Structures/Client.js index e37007d..d25008d 100644 --- a/Structures/Client.js +++ b/Structures/Client.js @@ -23,6 +23,12 @@ class Client extends Discord.Client { .readdirSync("./Commands") .filter((file) => file.endsWith(".js")); + const addonFiles = fs + .readdirSync("./Addons") + .filter((file) => file.endsWith(".js")); + + const addons = addonFiles.map((file) => require(`../Addons/${file}`)) + const commands = commandFiles.map((file) => require(`../Commands/${file}`)); console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬"); @@ -32,49 +38,49 @@ class Client extends Discord.Client { this.commands.set(cmd.name, cmd); }); - console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬"); - - // Addons - - const addonFiles = fs - .readdirSync("./Addons") - .filter((file) => file.endsWith(".js")); - - const addons = addonFiles.map((file) => require(`../Addons/${file}`)); - - console.log(" "); - console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬"); - addons.forEach((addon) => { - console.log(`\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, "Loaded"); + console.log(`\u001b[33m`, `[ADDON]`, `\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, "Loaded"); this.commands.set(addon.name, addon); }); - console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Addons ▬▬▬▬▬▬▬"); - console.log(" "); + console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬"); // Slash Commands const slashCommands = commands.map((cmd) => ({ - name: cmd.name.toLowerCase(), + name: cmd.name.toLowerCase(), description: cmd.description, permissions: [], options: cmd.slashCommandOptions, defaultPermission: true, + })) + + const slashCommands1 = addons.map((addon) => ({ + name: addon.name.toLowerCase(), + description: addon.description, + permissions: [], + options: addon.slashCommandOptions, + defaultPermission: true, })); this.removeAllListeners(); this.on("ready", async () => { - const cmds = await this.application?.commands.set(slashCommands); + const cmds = await this.application?.commands.set(slashCommands) + const addons = await this.application?.commands.set(slashCommands1) console.log(" "); console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬"), console.log(" "); cmds.forEach((cmd) => - console.log(`Slash Command ${cmd.name} registered`) + console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, `| Slash Command Registered`) ); + + addons.forEach((addon) => + console.log(`\u001b[33m`, `[ADDON]`, `\u001b[31;1m`,`${addon.name}`, `\u001b[32;1m`, `| Slash Command Registered`) + ); + }); console.log(" "); From bd26162e4a3964fefaf233a2f0979109f66dcb08 Mon Sep 17 00:00:00 2001 From: Noah Date: Mon, 25 Oct 2021 00:02:17 -0500 Subject: [PATCH 02/26] Fixed bug --- Structures/Client.js | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/Structures/Client.js b/Structures/Client.js index d25008d..bac8dd9 100644 --- a/Structures/Client.js +++ b/Structures/Client.js @@ -27,8 +27,8 @@ class Client extends Discord.Client { .readdirSync("./Addons") .filter((file) => file.endsWith(".js")); - const addons = addonFiles.map((file) => require(`../Addons/${file}`)) - + const addons = addonFiles.map((file) => require(`../Addons/${file}`)); + const commands = commandFiles.map((file) => require(`../Commands/${file}`)); console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Commands ▬▬▬▬▬▬▬"); @@ -39,7 +39,14 @@ class Client extends Discord.Client { }); addons.forEach((addon) => { - console.log(`\u001b[33m`, `[ADDON]`, `\u001b[31;1m`, `${addon.name}`, `\u001b[32;1m`, "Loaded"); + console.log( + `\u001b[33m`, + `[ADDON]`, + `\u001b[31;1m`, + `${addon.name}`, + `\u001b[32;1m`, + "Loaded" + ); this.commands.set(addon.name, addon); }); @@ -48,15 +55,15 @@ class Client extends Discord.Client { // Slash Commands const slashCommands = commands.map((cmd) => ({ - name: cmd.name.toLowerCase(), + name: cmd.name.toLowerCase(), description: cmd.description, permissions: [], options: cmd.slashCommandOptions, defaultPermission: true, - })) + })); const slashCommands1 = addons.map((addon) => ({ - name: addon.name.toLowerCase(), + name: addon.name.toLowerCase(), description: addon.description, permissions: [], options: addon.slashCommandOptions, @@ -66,21 +73,32 @@ class Client extends Discord.Client { this.removeAllListeners(); this.on("ready", async () => { - const cmds = await this.application?.commands.set(slashCommands) - const addons = await this.application?.commands.set(slashCommands1) + const allCommands = slashCommands.concat(slashCommands1); + await this.application?.commands.set(allCommands); console.log(" "); console.log(`\u001b[34;1m`, "▬▬▬▬▬▬▬ Slash Command ▬▬▬▬▬▬▬"), console.log(" "); - cmds.forEach((cmd) => - console.log(`\u001b[31;1m`, `${cmd.name}`, `\u001b[32;1m`, `| Slash Command Registered`) + slashCommands.forEach((cmd) => + console.log( + `\u001b[31;1m`, + `${cmd.name}`, + `\u001b[32;1m`, + `| Slash Command Registered` + ) ); - addons.forEach((addon) => - console.log(`\u001b[33m`, `[ADDON]`, `\u001b[31;1m`,`${addon.name}`, `\u001b[32;1m`, `| Slash Command Registered`) + slashCommands1.forEach((addon) => + console.log( + `\u001b[33m`, + `[ADDON]`, + `\u001b[31;1m`, + `${addon.name}`, + `\u001b[32;1m`, + `| Slash Command Registered` + ) ); - }); console.log(" "); From 55a42b88ae4aae9b76a0aa4a2b274151dc9b1d5a Mon Sep 17 00:00:00 2001 From: Noah Date: Mon, 25 Oct 2021 00:02:23 -0500 Subject: [PATCH 03/26] Ran prettier --- Commands/embed.js | 32 +++++++++++++------------------- Data/commands.yml | 2 -- Data/supportbot.yml | 2 +- Data/ticket-panel-id.yml | 2 +- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Commands/embed.js b/Commands/embed.js index 7b6db55..821c4d8 100644 --- a/Commands/embed.js +++ b/Commands/embed.js @@ -15,22 +15,20 @@ module.exports = new Command({ description: cmdconfig.EmbedCommandDesc, slashCommandOptions: [ { - name: "title", - description: "Embed Title", - type: "STRING", - }, + name: "title", + description: "Embed Title", + type: "STRING", + }, { name: "message", description: "Embed Message", type: "STRING", }, - ], permission: "SEND_MESSAGES", async run(interaction) { - let SupportStaff = interaction.guild.roles.cache.find( (SupportTeam) => SupportTeam.name === supportbot.Staff @@ -57,22 +55,18 @@ module.exports = new Command({ interaction.member.roles.cache.has(SupportStaff.id) || interaction.member.roles.cache.has(Admins.id) ) { + const EmbedTitle = interaction.options.getString("title"); + const EmbedSubject = interaction.options.getString("message"); - const EmbedTitle = interaction.options.getString("title") - const EmbedSubject = interaction.options.getString("message") - - const EmbedMsg = new Discord.MessageEmbed() - .setTitle(EmbedTitle) - .setDescription(EmbedSubject) - - interaction.reply({ - embeds: [EmbedMsg], - }); + const EmbedMsg = new Discord.MessageEmbed() + .setTitle(EmbedTitle) + .setDescription(EmbedSubject); + interaction.reply({ + embeds: [EmbedMsg], + }); } else { - return interaction.reply({ embeds: [NoPerms] }); + return interaction.reply({ embeds: [NoPerms] }); } - }, - }); diff --git a/Data/commands.yml b/Data/commands.yml index 8edc372..4d3b470 100644 --- a/Data/commands.yml +++ b/Data/commands.yml @@ -35,5 +35,3 @@ InfoCommandDesc: "Get information about the brand." PingCommandDesc: "Pong!" HelpCommandDesc: "Get a list of all the commands." EmbedCommandDesc: "Send a message as an embed." - - diff --git a/Data/supportbot.yml b/Data/supportbot.yml index a7f1cee..50b726a 100644 --- a/Data/supportbot.yml +++ b/Data/supportbot.yml @@ -18,7 +18,7 @@ SupportBot_Version: "7.2 pre-3" Name: "SupportBot" Prefix: "!" # Everything uses the new Slash (/) Commands feature! -Token: "BOT_TOKEN" +Token: "ODUwNTMxNzExNDkwMzI2NTI5.YLrFYg.2qDnbXB5sSEmK0HEfo5kz1LdFlk" # ------------------------- # Activity Configuration diff --git a/Data/ticket-panel-id.yml b/Data/ticket-panel-id.yml index 2912e7f..4bb76a5 100644 --- a/Data/ticket-panel-id.yml +++ b/Data/ticket-panel-id.yml @@ -1 +1 @@ -TicketPanelID: '' +TicketPanelID: "" From 3fc905c82eb7a66b0c6c21398087192e49d2fd03 Mon Sep 17 00:00:00 2001 From: Noah Date: Mon, 25 Oct 2021 00:03:28 -0500 Subject: [PATCH 04/26] Update supportbot.yml --- Data/supportbot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Data/supportbot.yml b/Data/supportbot.yml index 50b726a..0ae28a2 100644 --- a/Data/supportbot.yml +++ b/Data/supportbot.yml @@ -10,7 +10,7 @@ # Discord Support: https:#emeraldsrv.dev/discord # Community Resources: https:#emeraldsrv.dev/resources -SupportBot_Version: "7.2 pre-3" +SupportBot_Version: "7.2" # ------------------------- # General Configuration @@ -18,7 +18,7 @@ SupportBot_Version: "7.2 pre-3" Name: "SupportBot" Prefix: "!" # Everything uses the new Slash (/) Commands feature! -Token: "ODUwNTMxNzExNDkwMzI2NTI5.YLrFYg.2qDnbXB5sSEmK0HEfo5kz1LdFlk" +Token: "BOT_TOKEN" # ------------------------- # Activity Configuration From 284e8dc6f5db642b08340294baab4a797e867eb6 Mon Sep 17 00:00:00 2001 From: Noah Date: Mon, 25 Oct 2021 00:15:54 -0500 Subject: [PATCH 05/26] Fixed spelling --- Data/supportbot.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Data/supportbot.yml b/Data/supportbot.yml index 0ae28a2..98e87b4 100644 --- a/Data/supportbot.yml +++ b/Data/supportbot.yml @@ -7,8 +7,8 @@ # SupportBot created by Emerald Services # Installed with MIT License # -# Discord Support: https:#emeraldsrv.dev/discord -# Community Resources: https:#emeraldsrv.dev/resources +# Discord Support: https://emeraldsrv.dev/discord +# Community Resources: https://emeraldsrv.dev/resources SupportBot_Version: "7.2" @@ -17,7 +17,7 @@ SupportBot_Version: "7.2" # ------------------------- Name: "SupportBot" -Prefix: "!" # Everything uses the new Slash (/) Commands feature! +# No Prefix, as everything uses the new Slash (/) Commands feature! Token: "BOT_TOKEN" # ------------------------- From 465c422171879c3c8c4a64cddcf113ad182ef462 Mon Sep 17 00:00:00 2001 From: Noah Date: Mon, 25 Oct 2021 00:16:00 -0500 Subject: [PATCH 06/26] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index e69de29..01cd9e6 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,13 @@ +![imgur](https://i.imgur.com/TQj40Mt.png) + +## What is SupportBot? + +SupportBot is an open-sourced support system for discord. It's completely free to use with high amounts of customisation to match your own brand. + +## Quick Links + +**|** [Discord](https://emeraldsrv.dev/discord) **|** +[Hosting](https://emeraldsrv.dev/hosting) **|** +[Documentation](https://docs.emeraldsrv.dev) **|** +[Download via Polymart](https://polymart.org/resource/supportbot-1-discord-ticket-bot.518) **|** +[Download via MC-Market](https://www.mc-market.org/resources/8940/) **|** From 1c4032caa6e52dd4a1825d10f5595f0a85927397 Mon Sep 17 00:00:00 2001 From: Xiled Emerald Date: Mon, 25 Oct 2021 23:18:28 +0100 Subject: [PATCH 07/26] Create suggest.js --- Commands/suggest.js | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Commands/suggest.js diff --git a/Commands/suggest.js b/Commands/suggest.js new file mode 100644 index 0000000..68382a8 --- /dev/null +++ b/Commands/suggest.js @@ -0,0 +1,58 @@ +// SupportBot | Emerald Services +// Ping Command + +const fs = require("fs"); + +const Discord = require("discord.js"); +const yaml = require("js-yaml"); +const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); +const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); + +const Command = require("../Structures/Command.js"); + +module.exports = new Command({ + name: cmdconfig.SuggestCommand, + description: cmdconfig.SuggestCommandDesc, + slashCommandOptions: [ + { + name: "suggestion", + description: "Create a Suggestion", + type: "STRING", + }, + ], + permission: "SEND_MESSAGES", + + async run(interaction) { + + const suggestChannel = client.channels.cache.get(supportbot.SuggestionChannel); + + const NoChannel = new Discord.MessageEmbed() + .setTitle("Missing Channel!") + .setDescription(`${supportbot.InvalidChannel}`) + .setColor(supportbot.WarningColour); + + if (!suggestChannel) return interaction.reply({ embeds: [NoChannel] }); + + let suggestion = + interaction.options.getString("suggestion"); + + const SuggestEmbed = new Discord.MessageEmbed() + .addField("Suggestion", suggestion, true) + .addField("From", `<@${interaction.user.id}>`) + .setThumbnail(interaction.user.displayAvatarURL()) + .setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL()) + .setColor(supportbot.EmbedColour); + + suggestChannel.reply({ embeds: [SuggestEmbed ]}) + + const Submitted = new Discord.MessageEmbed() + .setTitle("Suggestion Submitted!") + .setDescription(`:white_check_mark: You have successfully submitted a suggestion.`) + .addField("Sent to:", `<#${suggestChannel.id}>`) + .setColor(supportbot.WarningColour); + + return interaction.reply({ embeds: [Submitted] }) + + }, + +}); From 3df591ec527efa1fbe77e93bdc27e234158adee4 Mon Sep 17 00:00:00 2001 From: Xiled Emerald Date: Mon, 25 Oct 2021 23:19:07 +0100 Subject: [PATCH 08/26] Update supportbot.yml --- Data/supportbot.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Data/supportbot.yml b/Data/supportbot.yml index 98e87b4..78ab5f4 100644 --- a/Data/supportbot.yml +++ b/Data/supportbot.yml @@ -73,6 +73,12 @@ Staff: "Support Team" Admin: "Project Developer" TicketBlackListRole: "Blacklisted" +# ---------------------------- +# Suggestions Configuration +# ---------------------------- + +SuggestionChannel: "suggestions" + # ------------------------- # Tickets Configuration # ------------------------- From 78dea91e1d1cf1d1ee4b70e4a21b4df1ed0fe837 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 19:20:10 -0500 Subject: [PATCH 09/26] Prettier --- Commands/suggest.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Commands/suggest.js b/Commands/suggest.js index 68382a8..1b7f221 100644 --- a/Commands/suggest.js +++ b/Commands/suggest.js @@ -15,16 +15,17 @@ module.exports = new Command({ description: cmdconfig.SuggestCommandDesc, slashCommandOptions: [ { - name: "suggestion", - description: "Create a Suggestion", - type: "STRING", - }, + name: "suggestion", + description: "Create a Suggestion", + type: "STRING", + }, ], permission: "SEND_MESSAGES", async run(interaction) { - - const suggestChannel = client.channels.cache.get(supportbot.SuggestionChannel); + const suggestChannel = client.channels.cache.get( + supportbot.SuggestionChannel + ); const NoChannel = new Discord.MessageEmbed() .setTitle("Missing Channel!") @@ -33,26 +34,25 @@ module.exports = new Command({ if (!suggestChannel) return interaction.reply({ embeds: [NoChannel] }); - let suggestion = - interaction.options.getString("suggestion"); + let suggestion = interaction.options.getString("suggestion"); const SuggestEmbed = new Discord.MessageEmbed() - .addField("Suggestion", suggestion, true) - .addField("From", `<@${interaction.user.id}>`) - .setThumbnail(interaction.user.displayAvatarURL()) - .setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL()) - .setColor(supportbot.EmbedColour); + .addField("Suggestion", suggestion, true) + .addField("From", `<@${interaction.user.id}>`) + .setThumbnail(interaction.user.displayAvatarURL()) + .setFooter(supportbot.EmbedFooter, interaction.user.displayAvatarURL()) + .setColor(supportbot.EmbedColour); - suggestChannel.reply({ embeds: [SuggestEmbed ]}) + suggestChannel.reply({ embeds: [SuggestEmbed] }); const Submitted = new Discord.MessageEmbed() .setTitle("Suggestion Submitted!") - .setDescription(`:white_check_mark: You have successfully submitted a suggestion.`) + .setDescription( + `:white_check_mark: You have successfully submitted a suggestion.` + ) .addField("Sent to:", `<#${suggestChannel.id}>`) .setColor(supportbot.WarningColour); - return interaction.reply({ embeds: [Submitted] }) - + return interaction.reply({ embeds: [Submitted] }); }, - }); From cddd5d0026382ca49974e549a00de08a434b6167 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 19:30:10 -0500 Subject: [PATCH 10/26] Moved configs from Data to Configs --- Addons/hello.js | 6 ++++-- Commands/TicketAdd.js | 6 ++++-- Commands/TicketRemove.js | 6 ++++-- Commands/closeticket.js | 6 ++++-- Commands/embed.js | 6 ++++-- Commands/help.js | 6 ++++-- Commands/info.js | 6 ++++-- Commands/ping.js | 6 ++++-- Commands/suggest.js | 6 ++++-- Commands/ticket.js | 6 ++++-- {Data => Configs}/commands.yml | 4 ++-- {Data => Configs}/supportbot.yml | 0 {Data => Configs}/ticket-panel.yml | 4 ++-- Data/ticket-panel-id.json | 3 +++ Data/ticket-panel-id.yml | 1 - Events/interactionCreate.js | 6 ++++-- Events/messageReactionAdd.js | 8 +++++--- Events/ready.js | 13 +++++++------ Structures/Addons.js | 4 +++- Structures/Client.js | 4 +++- Structures/Command.js | 4 +++- Structures/Event.js | 4 +++- Structures/TicketID.js | 4 +++- index.js | 4 +++- 24 files changed, 81 insertions(+), 42 deletions(-) rename {Data => Configs}/commands.yml (89%) rename {Data => Configs}/supportbot.yml (100%) rename {Data => Configs}/ticket-panel.yml (89%) create mode 100644 Data/ticket-panel-id.json delete mode 100644 Data/ticket-panel-id.yml diff --git a/Addons/hello.js b/Addons/hello.js index 6814478..e87b181 100644 --- a/Addons/hello.js +++ b/Addons/hello.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); // Your Addon Config file! Saved in /Addons/Settings/YourAddonConfig.yml // const exampleaddon = yaml.load(fs.readFileSync('./Addons/Settings/YourAddonConfig.yml', 'utf8')); diff --git a/Commands/TicketAdd.js b/Commands/TicketAdd.js index 21ce019..42e34a2 100644 --- a/Commands/TicketAdd.js +++ b/Commands/TicketAdd.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); diff --git a/Commands/TicketRemove.js b/Commands/TicketRemove.js index f5d673e..5e1ed3c 100644 --- a/Commands/TicketRemove.js +++ b/Commands/TicketRemove.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); diff --git a/Commands/closeticket.js b/Commands/closeticket.js index c9ed693..6928817 100644 --- a/Commands/closeticket.js +++ b/Commands/closeticket.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); const TicketNumberID = require("../Structures/TicketID.js"); diff --git a/Commands/embed.js b/Commands/embed.js index 821c4d8..9bff3a8 100644 --- a/Commands/embed.js +++ b/Commands/embed.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); diff --git a/Commands/help.js b/Commands/help.js index 8df6568..bc02091 100644 --- a/Commands/help.js +++ b/Commands/help.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); diff --git a/Commands/info.js b/Commands/info.js index 289ce07..b93dcf9 100644 --- a/Commands/info.js +++ b/Commands/info.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); diff --git a/Commands/ping.js b/Commands/ping.js index 799b1f4..edf812d 100644 --- a/Commands/ping.js +++ b/Commands/ping.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); diff --git a/Commands/suggest.js b/Commands/suggest.js index 1b7f221..52ebf16 100644 --- a/Commands/suggest.js +++ b/Commands/suggest.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); diff --git a/Commands/ticket.js b/Commands/ticket.js index f1a65d8..474932e 100644 --- a/Commands/ticket.js +++ b/Commands/ticket.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Command = require("../Structures/Command.js"); const TicketNumberID = require("../Structures/TicketID.js"); diff --git a/Data/commands.yml b/Configs/commands.yml similarity index 89% rename from Data/commands.yml rename to Configs/commands.yml index 4d3b470..37f7cb0 100644 --- a/Data/commands.yml +++ b/Configs/commands.yml @@ -7,8 +7,8 @@ # SupportBot created by Emerald Services # Installed with MIT License # -# Discord Support: https:#emeraldsrv.dev/discord -# Community Resources: https:#emeraldsrv.dev/resources +# Discord Support: https://emeraldsrv.dev/discord +# Community Resources: https://emeraldsrv.dev/resources # ------------------------------- # Command Name Configuration diff --git a/Data/supportbot.yml b/Configs/supportbot.yml similarity index 100% rename from Data/supportbot.yml rename to Configs/supportbot.yml diff --git a/Data/ticket-panel.yml b/Configs/ticket-panel.yml similarity index 89% rename from Data/ticket-panel.yml rename to Configs/ticket-panel.yml index baeca8d..10f37bf 100644 --- a/Data/ticket-panel.yml +++ b/Configs/ticket-panel.yml @@ -7,8 +7,8 @@ # SupportBot created by Emerald Services # Installed with MIT License # -# Discord Support: https:#emeraldsrv.dev/discord -# Community Resources: https:#emeraldsrv.dev/resources +# Discord Support: https://emeraldsrv.dev/discord +# Community Resources: https://emeraldsrv.dev/resources # ------------------------------- # Ticket Panel Configuration diff --git a/Data/ticket-panel-id.json b/Data/ticket-panel-id.json new file mode 100644 index 0000000..b2367c6 --- /dev/null +++ b/Data/ticket-panel-id.json @@ -0,0 +1,3 @@ +{ + "TicketPanelID": "" +} diff --git a/Data/ticket-panel-id.yml b/Data/ticket-panel-id.yml deleted file mode 100644 index 4bb76a5..0000000 --- a/Data/ticket-panel-id.yml +++ /dev/null @@ -1 +0,0 @@ -TicketPanelID: "" diff --git a/Events/interactionCreate.js b/Events/interactionCreate.js index 7b06425..14960f9 100644 --- a/Events/interactionCreate.js +++ b/Events/interactionCreate.js @@ -5,8 +5,10 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); +const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8")); const Event = require("../Structures/Event.js"); diff --git a/Events/messageReactionAdd.js b/Events/messageReactionAdd.js index 22d20d6..9f6f66b 100644 --- a/Events/messageReactionAdd.js +++ b/Events/messageReactionAdd.js @@ -5,10 +5,12 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); -const cmdconfig = yaml.load(fs.readFileSync("./Data/commands.yml", "utf8")); +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("./Data/ticket-panel.yml", "utf8") + fs.readFileSync("./Configs/ticket-panel.yml", "utf8") ); const Event = require("../Structures/Event.js"); diff --git a/Events/ready.js b/Events/ready.js index 872e412..fc87ab4 100644 --- a/Events/ready.js +++ b/Events/ready.js @@ -5,9 +5,11 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); const panelconfig = yaml.load( - fs.readFileSync("./Data/ticket-panel.yml", "utf8") + fs.readFileSync("./Configs/ticket-panel.yml", "utf8") ); const Event = require("../Structures/Event.js"); @@ -77,8 +79,8 @@ module.exports = new Event("ready", (client) => { return false; } - const panelid = yaml.load( - fs.readFileSync("./Data/ticket-panel-id.yml", "utf8") + const panelid = JSON.parse( + fs.readFileSync("./Data/ticket-panel-id.json", "utf8") ); chan1.messages.fetch(panelid.TicketPanelID).catch(async (r) => { @@ -115,8 +117,7 @@ module.exports = new Event("ready", (client) => { let data = { TicketPanelID: `${r.id}`, }; - let yamlStr = yaml.dump(data); - fs.writeFileSync("./Data/ticket-panel-id.yml", yamlStr, "utf8"); + fs.writeFileSync("./Data/ticket-panel-id.json", data, "utf8"); }) .catch((e) => { console.log("Raw" + e); diff --git a/Structures/Addons.js b/Structures/Addons.js index d5c8935..95b24f7 100644 --- a/Structures/Addons.js +++ b/Structures/Addons.js @@ -6,7 +6,9 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); function RunFunction(interaction) {} diff --git a/Structures/Client.js b/Structures/Client.js index bac8dd9..e70422d 100644 --- a/Structures/Client.js +++ b/Structures/Client.js @@ -9,7 +9,9 @@ const Event = require("./Event.js"); const intents = new Discord.Intents(32767); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); class Client extends Discord.Client { constructor() { diff --git a/Structures/Command.js b/Structures/Command.js index a075110..ba663b5 100644 --- a/Structures/Command.js +++ b/Structures/Command.js @@ -6,7 +6,9 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); function RunFunction(interaction) {} diff --git a/Structures/Event.js b/Structures/Event.js index 8f81bf1..61e4381 100644 --- a/Structures/Event.js +++ b/Structures/Event.js @@ -6,7 +6,9 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); function RunFunction(client, ...eventArgs) {} diff --git a/Structures/TicketID.js b/Structures/TicketID.js index e0f0d80..11c9d9f 100644 --- a/Structures/TicketID.js +++ b/Structures/TicketID.js @@ -9,7 +9,9 @@ const Client = require("./Client.js"); const Event = require("./Event.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); class TicketNumberID { static pad(guildId) { diff --git a/index.js b/index.js index ed48bb2..db39ccc 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,9 @@ const fs = require("fs"); const Discord = require("discord.js"); const yaml = require("js-yaml"); -const supportbot = yaml.load(fs.readFileSync("./Data/supportbot.yml", "utf8")); +const supportbot = yaml.load( + fs.readFileSync("./Configs/supportbot.yml", "utf8") +); const Client = require("./Structures/Client.js"); const client = new Client({}); From 6c14a6a06c1bcd12c2df472e5358f683ea5b4dd3 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 19:39:07 -0500 Subject: [PATCH 11/26] Rename --- Commands/TicketAdd.js => commands/add.js | 4 +--- Commands/TicketRemove.js => commands/remove.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) rename Commands/TicketAdd.js => commands/add.js (96%) rename Commands/TicketRemove.js => commands/remove.js (96%) diff --git a/Commands/TicketAdd.js b/commands/add.js similarity index 96% rename from Commands/TicketAdd.js rename to commands/add.js index 42e34a2..5aee916 100644 --- a/Commands/TicketAdd.js +++ b/commands/add.js @@ -58,9 +58,7 @@ module.exports = new Command({ interaction.member.roles.cache.has(SupportStaff.id) || interaction.member.roles.cache.has(Admins.id) ) { - if ( - !interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`) - ) { + if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") .setDescription(`${supportbot.NoValidTicket}`) diff --git a/Commands/TicketRemove.js b/commands/remove.js similarity index 96% rename from Commands/TicketRemove.js rename to commands/remove.js index 5e1ed3c..d062584 100644 --- a/Commands/TicketRemove.js +++ b/commands/remove.js @@ -58,9 +58,7 @@ module.exports = new Command({ interaction.member.roles.cache.has(SupportStaff.id) || interaction.member.roles.cache.has(Admins.id) ) { - if ( - !interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`) - ) { + if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") .setDescription(`${supportbot.NoValidTicket}`) From a6b105a2e136a2a8a9b4aa53cceb287c2af0b9d4 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 19:48:00 -0500 Subject: [PATCH 12/26] Updated config defaults --- Commands/closeticket.js | 3 ++- Commands/ticket.js | 4 ++-- Configs/supportbot.yml | 12 ++++++------ Events/interactionCreate.js | 5 +++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Commands/closeticket.js b/Commands/closeticket.js index 6928817..682fb8f 100644 --- a/Commands/closeticket.js +++ b/Commands/closeticket.js @@ -32,7 +32,7 @@ module.exports = new Command({ permission: "SEND_MESSAGES", async run(interaction) { - if (!interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) { + if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") .setDescription(`${supportbot.NoValidTicket}`) @@ -97,6 +97,7 @@ module.exports = new Command({ msgs = msgs.sort( (a, b) => a.createdTimestamp - b.createdTimestamp ); + html += ``; html += `Server Name: ${interaction.guild.name}
`; html += `Ticket: ${ticketChannel.name}
`; html += `Message: ${msgs.size} Messages


`; diff --git a/Commands/ticket.js b/Commands/ticket.js index 474932e..fd3f93f 100644 --- a/Commands/ticket.js +++ b/Commands/ticket.js @@ -66,7 +66,7 @@ module.exports = new Command({ if ( interaction.guild.channels.cache.find( (ticketChannel) => - ticketChannel.name === `${supportbot.TicketChannel}-${ticketNumberID}` + ticketChannel.name === `${supportbot.TicketPrefix}${ticketNumberID}` ) ) { return interaction.reply({ embeds: [TicketExists] }); @@ -115,7 +115,7 @@ module.exports = new Command({ const Author = interaction.user; const Everyone = interaction.guild.id; const ticketChannel = await interaction.guild.channels.create( - `${supportbot.TicketChannel}-${ticketNumberID}`, + `${supportbot.TicketPrefix}${ticketNumberID}`, { type: "GUILD_TEXT", } diff --git a/Configs/supportbot.yml b/Configs/supportbot.yml index 78ab5f4..d6d6418 100644 --- a/Configs/supportbot.yml +++ b/Configs/supportbot.yml @@ -69,8 +69,8 @@ AutoRole: true AutoRole_Role: "Member" LockdownRole: "@everyone" -Staff: "Support Team" -Admin: "Project Developer" +Staff: "Staff" +Admin: "Admin" TicketBlackListRole: "Blacklisted" # ---------------------------- @@ -83,11 +83,11 @@ SuggestionChannel: "suggestions" # Tickets Configuration # ------------------------- -TicketCategory: "▬▬ TICKETS ▬▬" -TicketChannel: "ticket" +TicketCategory: "Tickets" +TicketPrefix: "ticket-" # The prefix for ticket channel names -TicketLog: "ticket-log" -TranscriptLog: "ticket-data" +TicketLog: "logs" +TranscriptLog: "transcripts" TranscriptTitle: "Ticket Transcript" TicketLog_Title: "Ticket Log" diff --git a/Events/interactionCreate.js b/Events/interactionCreate.js index 14960f9..9a9c95d 100644 --- a/Events/interactionCreate.js +++ b/Events/interactionCreate.js @@ -57,7 +57,7 @@ module.exports = new Event("interactionCreate", (client, interaction) => { } if (interaction.customId === "ticketclose") { - if (interaction.channel.name.startsWith(`${supportbot.TicketChannel}-`)) { + if (interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { interaction.message.fetch(); interaction.deferUpdate(); const DeleteTicketEmbed = new Discord.MessageEmbed() @@ -94,6 +94,7 @@ module.exports = new Event("interactionCreate", (client, interaction) => { msgs = msgs.sort( (a, b) => a.createdTimestamp - b.createdTimestamp ); + html += ``; html += `Server Name: ${interaction.guild.name}
`; html += `Ticket: ${ticketChannel.name}
`; html += `Message: ${msgs.size} Messages


`; @@ -126,7 +127,7 @@ module.exports = new Event("interactionCreate", (client, interaction) => { } } if (interaction.customId === "ticketlock") { - if (interaction.channel.name.startsWith(`${supportbot.TicketChannel}`)) { + if (interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { interaction.message.fetch(); interaction.deferUpdate(); let Admin = From 8a2059f0874194eb4725a9f1dad61608997bbfa6 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 20:05:45 -0500 Subject: [PATCH 13/26] Fixed suggest command bug --- Configs/commands.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Configs/commands.yml b/Configs/commands.yml index 37f7cb0..1e56d35 100644 --- a/Configs/commands.yml +++ b/Configs/commands.yml @@ -22,6 +22,7 @@ InfoCommand: "info" PingCommand: "ping" HelpCommand: "help" EmbedCommand: "embed" +SuggestCommand: "suggest" # --------------------------------------- # Command Description Configuration @@ -35,3 +36,4 @@ InfoCommandDesc: "Get information about the brand." PingCommandDesc: "Pong!" HelpCommandDesc: "Get a list of all the commands." EmbedCommandDesc: "Send a message as an embed." +SuggestCommandDesc: "Suggest a feature for the server." From 4cb45beded2c10ae09bb378cf4a10a0bbbb866d0 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 20:18:06 -0500 Subject: [PATCH 14/26] Fixed bug --- Commands/ticket.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Commands/ticket.js b/Commands/ticket.js index fd3f93f..27329fd 100644 --- a/Commands/ticket.js +++ b/Commands/ticket.js @@ -64,10 +64,9 @@ module.exports = new Command({ .setColor(supportbot.WarningColour); if ( - interaction.guild.channels.cache.find( - (ticketChannel) => - ticketChannel.name === `${supportbot.TicketPrefix}${ticketNumberID}` - ) + await interaction.guild.channels.cache.find((ticketChannel) => { + ticketChannel.name === `${supportbot.TicketPrefix}${ticketNumberID}`; + }) ) { return interaction.reply({ embeds: [TicketExists] }); } From 019bb4842fea348874ee7b1882b19943900dd7a3 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 20:19:27 -0500 Subject: [PATCH 15/26] Fixed bug --- Events/ready.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Events/ready.js b/Events/ready.js index fc87ab4..24bfa7f 100644 --- a/Events/ready.js +++ b/Events/ready.js @@ -117,7 +117,11 @@ module.exports = new Event("ready", (client) => { let data = { TicketPanelID: `${r.id}`, }; - fs.writeFileSync("./Data/ticket-panel-id.json", data, "utf8"); + fs.writeFileSync( + "./Data/ticket-panel-id.json", + JSON.stringify(data), + "utf8" + ); }) .catch((e) => { console.log("Raw" + e); From 1e89057006e5b29ec4f54798d4a4ff1b7b7da40d Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 20:19:33 -0500 Subject: [PATCH 16/26] Added font --- Events/interactionCreate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Events/interactionCreate.js b/Events/interactionCreate.js index 9a9c95d..d7e67a1 100644 --- a/Events/interactionCreate.js +++ b/Events/interactionCreate.js @@ -94,7 +94,7 @@ module.exports = new Event("interactionCreate", (client, interaction) => { msgs = msgs.sort( (a, b) => a.createdTimestamp - b.createdTimestamp ); - html += ``; + html += ``; html += `Server Name: ${interaction.guild.name}
`; html += `Ticket: ${ticketChannel.name}
`; html += `Message: ${msgs.size} Messages


`; From f2ea9650c4fc3067859ff231c1f0dfb48f708b63 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 20:24:10 -0500 Subject: [PATCH 17/26] Renamed file --- Commands/closeticket.js => commands/close.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Commands/closeticket.js => commands/close.js (100%) diff --git a/Commands/closeticket.js b/commands/close.js similarity index 100% rename from Commands/closeticket.js rename to commands/close.js From e039048fc6b69336d07f427e37cd1910612ae612 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 20:24:26 -0500 Subject: [PATCH 18/26] Updated role defaults --- Configs/supportbot.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Configs/supportbot.yml b/Configs/supportbot.yml index d6d6418..d1e9608 100644 --- a/Configs/supportbot.yml +++ b/Configs/supportbot.yml @@ -171,9 +171,9 @@ DepartmentTitle_2: "Billing Support" DepartmentTitle_3: "Admin Team" # Ticket department title, This is the title for a ticket department to help users know what is available. -DepartmentRole_1: "Support Team" -DepartmentRole_2: "Support Team" -DepartmentRole_3: "Project Developer" +DepartmentRole_1: "Support" +DepartmentRole_2: "Support" +DepartmentRole_3: "Admin" # Ticket roles are the roles that will be able to gain access to tickets depending on what department has been chosen. # --- Closing Config --- From ed583deb315148c1e8337d0f925510fea90cd83d Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 27 Oct 2021 20:44:10 -0500 Subject: [PATCH 19/26] Updated css --- commands/close.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/close.js b/commands/close.js index 682fb8f..2a29c8a 100644 --- a/commands/close.js +++ b/commands/close.js @@ -97,7 +97,7 @@ module.exports = new Command({ msgs = msgs.sort( (a, b) => a.createdTimestamp - b.createdTimestamp ); - html += ``; + html += ``; html += `Server Name: ${interaction.guild.name}
`; html += `Ticket: ${ticketChannel.name}
`; html += `Message: ${msgs.size} Messages


`; @@ -183,6 +183,7 @@ module.exports = new Command({ msgs = msgs.sort( (a, b) => a.createdTimestamp - b.createdTimestamp ); + html += ``; html += `Server Name: ${interaction.guild.name}
`; html += `Ticket: ${ticketChannel.name}
`; html += `Message: ${msgs.size} Messages


`; From 0610df940090aba465fa1e6f64e5602d736a2deb Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 28 Oct 2021 18:03:06 -0500 Subject: [PATCH 20/26] Create add.js --- Commands/add.js | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Commands/add.js diff --git a/Commands/add.js b/Commands/add.js new file mode 100644 index 0000000..5aee916 --- /dev/null +++ b/Commands/add.js @@ -0,0 +1,95 @@ +// SupportBot | Emerald Services +// Ticket Add Command + +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 Command = require("../Structures/Command.js"); + +async function asyncForEach(array, callback) { + for (let index = 0; index < array.length; index++) { + await callback(array[index], index, array); + } +} + +module.exports = new Command({ + name: cmdconfig.TicketAdd, + description: cmdconfig.TicketAddDesc, + slashCommandOptions: [ + { + name: "user", + description: "User to add", + type: "USER", + required: true, + }, + ], + permission: "SEND_MESSAGES", + + async run(interaction) { + let SupportStaff = + interaction.guild.roles.cache.find( + (SupportTeam) => SupportTeam.name === supportbot.Staff + ) || + interaction.guild.roles.cache.find( + (SupportTeam) => SupportTeam.id === supportbot.Staff + ); + let Admins = + interaction.guild.roles.cache.find( + (AdminUser) => AdminUser.name === supportbot.Admin + ) || + interaction.guild.roles.cache.find( + (AdminUser) => AdminUser.id === supportbot.Admin + ); + + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription( + `${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\`` + ) + .setColor(supportbot.WarningColour); + + if ( + interaction.member.roles.cache.has(SupportStaff.id) || + interaction.member.roles.cache.has(Admins.id) + ) { + if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { + const Exists = new Discord.MessageEmbed() + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) + .setColor(supportbot.WarningColour); + return interaction.reply({ embeds: [Exists] }); + } + + let uMember = interaction.options.getUser("user"); + const UserNotExist = new Discord.MessageEmbed() + .setTitle("User Not Found!") + .setDescription( + `${supportbot.UserNotFound}\n\nTry Again:\`/${cmdconfig.TicketAdd} \`` + ) + .setColor(supportbot.ErrorColour); + + if (!uMember) return interaction.reply({ embeds: [UserNotExist] }); + + interaction.channel.permissionOverwrites.edit(uMember, { + VIEW_CHANNEL: true, + READ_MESSAGE_HISTORY: true, + SEND_MESSAGES: true, + }); + + const Complete = new Discord.MessageEmbed() + .setTitle("User Added!") + .setDescription(supportbot.AddedUser.replace(/%user%/g, uMember.id)) + .setTimestamp() + .setColor(supportbot.EmbedColour); + interaction.reply({ embeds: [Complete] }); + } else { + return interaction.reply({ embeds: [NoPerms] }); + } + }, +}); From a397de2b9f48faf0072128b439aeaaa09f7af617 Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 28 Oct 2021 18:03:27 -0500 Subject: [PATCH 21/26] Create close.js --- Commands/close.js | 231 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 Commands/close.js diff --git a/Commands/close.js b/Commands/close.js new file mode 100644 index 0000000..2a29c8a --- /dev/null +++ b/Commands/close.js @@ -0,0 +1,231 @@ +// SupportBot | Emerald Services +// Close Ticket Command + +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 Command = require("../Structures/Command.js"); +const TicketNumberID = require("../Structures/TicketID.js"); + +async function asyncForEach(array, callback) { + for (let index = 0; index < array.length; index++) { + await callback(array[index], index, array); + } +} + +module.exports = new Command({ + name: cmdconfig.CloseTicket, + description: cmdconfig.CloseTicketDesc, + slashCommandOptions: [ + { + name: "reason", + description: "Ticket Close Reason", + type: "STRING", + }, + ], + permission: "SEND_MESSAGES", + + async run(interaction) { + if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { + const Exists = new Discord.MessageEmbed() + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) + .setColor(supportbot.WarningColour); + return interaction.reply({ embed: Exists }); + } + + if (supportbot.CloseConfirmation) { + const CloseTicketRequest = new Discord.MessageEmbed() + .setTitle(`**${supportbot.ClosingTicket}**`) + .setDescription( + `Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` ` + ) + .setColor(supportbot.EmbedColour); + + interaction + .reply(CloseTicketRequest) + .then((m) => { + interaction.channel + .awaitMessages( + (response) => + response.content.toLowerCase() === + supportbot.ClosingConfirmation_Word, + { + max: 1, + time: 20000, + errors: ["time"], + } + ) + .then((collected) => { + let logChannel = + interaction.guild.channels.cache.find( + (channel) => channel.name === supportbot.TranscriptLog + ) || + interaction.guild.channels.cache.find( + (channel) => channel.id === supportbot.TranscriptLog + ); + let user = interaction.user; + let reason = + interaction.options.getString("reason") || + "No Reason Provided."; + + let name = interaction.channel.name; + let ticketChannel = interaction.channel; + + interaction + .reply(`**${supportbot.ClosingTicket}**`) + + .then(() => { + const logEmbed = new Discord.MessageEmbed() + .setTitle(supportbot.TranscriptTitle) + .setColor(supportbot.EmbedColour) + .setFooter(supportbot.EmbedFooter) + .addField("Closed By", interaction.user.tag) + .addField("Reason", reason); + + interaction.channel.interactions + .fetch({ limit: 100 }) + .then((msgs) => { + let html = ""; + + msgs = msgs.sort( + (a, b) => a.createdTimestamp - b.createdTimestamp + ); + html += ``; + html += `Server Name: ${interaction.guild.name}
`; + html += `Ticket: ${ticketChannel.name}
`; + html += `Message: ${msgs.size} Messages


`; + + msgs.forEach((msg) => { + if (msg.content) { + html += `User: ${msg.author.tag}
`; + html += `Message: ${msg.content}
`; + html += `-----

`; + } + }); + + logChannel.send({ embeds: [logEmbed] }).catch((err) => { + interaction.reply(err); + }); + + let file = new Discord.MessageAttachment( + Buffer.from(html), + `${name}.html` + ); + logChannel + .send({ embeds: [logEmbed], files: [file] }) + .catch((err) => { + interaction.reply(err); + }); + + interaction.channel.delete().catch((error) => { + if ( + error.code !== + Discord.Constants.APIErrors.UNKNOWN_CHANNEL + ) { + console.error( + "Failed to delete the interaction:", + error + ); + } + }); + }); + }); + }); + }) + .catch(() => { + interaction + .followUp({ + content: "The request to close the ticket has timed out.", + }) + .then((m2) => setTimeout(() => interaction.channel.delete(3000))); + }); + } + + if (!supportbot.CloseConfirmation) { + let logChannel = + interaction.guild.channels.cache.find( + (channel) => channel.name === supportbot.TranscriptLog + ) || + interaction.guild.channels.cache.find( + (channel) => channel.id === supportbot.TranscriptLog + ); + let user = interaction.user; + let reason = + (await interaction.options.getString("reason")) || + "No Reason Provided."; + + let name = interaction.channel.name; + let ticketChannel = interaction.channel; + + interaction + .reply(`**${supportbot.ClosingTicket}**`) + + .then(() => { + const logEmbed = new Discord.MessageEmbed() + .setTitle(supportbot.TranscriptTitle) + .setColor(supportbot.EmbedColour) + .setFooter(supportbot.EmbedFooter) + .addField("Closed By", interaction.user.tag) + .addField("Reason", reason); + + interaction.channel.interactions + .fetch({ limit: 100 }) + .then((msgs) => { + let html = ""; + + msgs = msgs.sort( + (a, b) => a.createdTimestamp - b.createdTimestamp + ); + html += ``; + html += `Server Name: ${interaction.guild.name}
`; + html += `Ticket: ${ticketChannel.name}
`; + html += `Message: ${msgs.size} Messages


`; + + msgs.forEach((msg) => { + if (msg.content) { + html += `User: ${msg.author.tag}
`; + html += `Message: ${msg.content}
`; + html += `-----

`; + } + }); + + logChannel.send({ embeds: [logEmbed] }).catch((err) => { + interaction.reply(err); + }); + + let file = new Discord.MessageAttachment( + Buffer.from(html), + `${name}.html` + ); + logChannel + .send({ embeds: [logEmbed], files: [file] }) + .catch((err) => { + interaction.reply(err); + }); + + interaction.channel.delete().catch((error) => { + if ( + error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL + ) { + console.error("Failed to delete the interaction:", error); + } + }); + }); + }) + .catch(() => { + interaction + .followUp({ + content: "The request to close the ticket has timed out.", + }) + .then((m2) => setTimeout(() => interaction.channel.delete(3000))); + }); + } + }, +}); From ee7d42196da5adab0f309bb900982647d5d63d97 Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 28 Oct 2021 18:03:51 -0500 Subject: [PATCH 22/26] Create remove.js --- Commands/remove.js | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Commands/remove.js diff --git a/Commands/remove.js b/Commands/remove.js new file mode 100644 index 0000000..d062584 --- /dev/null +++ b/Commands/remove.js @@ -0,0 +1,95 @@ +// SupportBot | Emerald Services +// Ticket Remove Command + +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 Command = require("../Structures/Command.js"); + +async function asyncForEach(array, callback) { + for (let index = 0; index < array.length; index++) { + await callback(array[index], index, array); + } +} + +module.exports = new Command({ + name: cmdconfig.TicketRemove, + description: cmdconfig.TicketRemoveDesc, + slashCommandOptions: [ + { + name: "user", + description: "User to remove", + type: "USER", + required: true, + }, + ], + permission: "SEND_MESSAGES", + + async run(interaction) { + let SupportStaff = + interaction.guild.roles.cache.find( + (SupportTeam) => SupportTeam.name === supportbot.Staff + ) || + interaction.guild.roles.cache.find( + (SupportTeam) => SupportTeam.id === supportbot.Staff + ); + let Admins = + interaction.guild.roles.cache.find( + (AdminUser) => AdminUser.name === supportbot.Admin + ) || + interaction.guild.roles.cache.find( + (AdminUser) => AdminUser.id === supportbot.Admin + ); + + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription( + `${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\`` + ) + .setColor(supportbot.WarningColour); + + if ( + interaction.member.roles.cache.has(SupportStaff.id) || + interaction.member.roles.cache.has(Admins.id) + ) { + if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { + const Exists = new Discord.MessageEmbed() + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) + .setColor(supportbot.WarningColour); + return interaction.reply({ embeds: [Exists] }); + } + + let uMember = interaction.options.getUser("user"); + const UserNotExist = new Discord.MessageEmbed() + .setTitle("User Not Found!") + .setDescription( + `${supportbot.UserNotFound}\n\nTry Again:\`/${cmdconfig.TicketRemove} \`` + ) + .setColor(supportbot.ErrorColour); + + if (!uMember) return interaction.reply({ embeds: [UserNotExist] }); + + interaction.channel.permissionOverwrites.edit(uMember, { + VIEW_CHANNEL: false, + READ_MESSAGE_HISTORY: false, + SEND_MESSAGES: false, + }); + + const Complete = new Discord.MessageEmbed() + .setTitle("User Removed!") + .setDescription(supportbot.RemovedUser.replace(/%user%/g, uMember.id)) + .setTimestamp() + .setColor(supportbot.EmbedColour); + interaction.reply({ embeds: [Complete] }); + } else { + return interaction.reply({ embeds: [NoPerms] }); + } + }, +}); From 250583f8597246e570b416ba3a8144d511370888 Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 28 Oct 2021 18:04:26 -0500 Subject: [PATCH 23/26] Delete commands directory --- commands/add.js | 95 ------------------- commands/close.js | 231 --------------------------------------------- commands/remove.js | 95 ------------------- 3 files changed, 421 deletions(-) delete mode 100644 commands/add.js delete mode 100644 commands/close.js delete mode 100644 commands/remove.js diff --git a/commands/add.js b/commands/add.js deleted file mode 100644 index 5aee916..0000000 --- a/commands/add.js +++ /dev/null @@ -1,95 +0,0 @@ -// SupportBot | Emerald Services -// Ticket Add Command - -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 Command = require("../Structures/Command.js"); - -async function asyncForEach(array, callback) { - for (let index = 0; index < array.length; index++) { - await callback(array[index], index, array); - } -} - -module.exports = new Command({ - name: cmdconfig.TicketAdd, - description: cmdconfig.TicketAddDesc, - slashCommandOptions: [ - { - name: "user", - description: "User to add", - type: "USER", - required: true, - }, - ], - permission: "SEND_MESSAGES", - - async run(interaction) { - let SupportStaff = - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.name === supportbot.Staff - ) || - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.id === supportbot.Staff - ); - let Admins = - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.name === supportbot.Admin - ) || - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.id === supportbot.Admin - ); - - const NoPerms = new Discord.MessageEmbed() - .setTitle("Invalid Permissions!") - .setDescription( - `${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\`` - ) - .setColor(supportbot.WarningColour); - - if ( - interaction.member.roles.cache.has(SupportStaff.id) || - interaction.member.roles.cache.has(Admins.id) - ) { - if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { - const Exists = new Discord.MessageEmbed() - .setTitle("No Ticket Found!") - .setDescription(`${supportbot.NoValidTicket}`) - .setColor(supportbot.WarningColour); - return interaction.reply({ embeds: [Exists] }); - } - - let uMember = interaction.options.getUser("user"); - const UserNotExist = new Discord.MessageEmbed() - .setTitle("User Not Found!") - .setDescription( - `${supportbot.UserNotFound}\n\nTry Again:\`/${cmdconfig.TicketAdd} \`` - ) - .setColor(supportbot.ErrorColour); - - if (!uMember) return interaction.reply({ embeds: [UserNotExist] }); - - interaction.channel.permissionOverwrites.edit(uMember, { - VIEW_CHANNEL: true, - READ_MESSAGE_HISTORY: true, - SEND_MESSAGES: true, - }); - - const Complete = new Discord.MessageEmbed() - .setTitle("User Added!") - .setDescription(supportbot.AddedUser.replace(/%user%/g, uMember.id)) - .setTimestamp() - .setColor(supportbot.EmbedColour); - interaction.reply({ embeds: [Complete] }); - } else { - return interaction.reply({ embeds: [NoPerms] }); - } - }, -}); diff --git a/commands/close.js b/commands/close.js deleted file mode 100644 index 2a29c8a..0000000 --- a/commands/close.js +++ /dev/null @@ -1,231 +0,0 @@ -// SupportBot | Emerald Services -// Close Ticket Command - -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 Command = require("../Structures/Command.js"); -const TicketNumberID = require("../Structures/TicketID.js"); - -async function asyncForEach(array, callback) { - for (let index = 0; index < array.length; index++) { - await callback(array[index], index, array); - } -} - -module.exports = new Command({ - name: cmdconfig.CloseTicket, - description: cmdconfig.CloseTicketDesc, - slashCommandOptions: [ - { - name: "reason", - description: "Ticket Close Reason", - type: "STRING", - }, - ], - permission: "SEND_MESSAGES", - - async run(interaction) { - if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { - const Exists = new Discord.MessageEmbed() - .setTitle("No Ticket Found!") - .setDescription(`${supportbot.NoValidTicket}`) - .setColor(supportbot.WarningColour); - return interaction.reply({ embed: Exists }); - } - - if (supportbot.CloseConfirmation) { - const CloseTicketRequest = new Discord.MessageEmbed() - .setTitle(`**${supportbot.ClosingTicket}**`) - .setDescription( - `Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` ` - ) - .setColor(supportbot.EmbedColour); - - interaction - .reply(CloseTicketRequest) - .then((m) => { - interaction.channel - .awaitMessages( - (response) => - response.content.toLowerCase() === - supportbot.ClosingConfirmation_Word, - { - max: 1, - time: 20000, - errors: ["time"], - } - ) - .then((collected) => { - let logChannel = - interaction.guild.channels.cache.find( - (channel) => channel.name === supportbot.TranscriptLog - ) || - interaction.guild.channels.cache.find( - (channel) => channel.id === supportbot.TranscriptLog - ); - let user = interaction.user; - let reason = - interaction.options.getString("reason") || - "No Reason Provided."; - - let name = interaction.channel.name; - let ticketChannel = interaction.channel; - - interaction - .reply(`**${supportbot.ClosingTicket}**`) - - .then(() => { - const logEmbed = new Discord.MessageEmbed() - .setTitle(supportbot.TranscriptTitle) - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter) - .addField("Closed By", interaction.user.tag) - .addField("Reason", reason); - - interaction.channel.interactions - .fetch({ limit: 100 }) - .then((msgs) => { - let html = ""; - - msgs = msgs.sort( - (a, b) => a.createdTimestamp - b.createdTimestamp - ); - html += ``; - html += `Server Name: ${interaction.guild.name}
`; - html += `Ticket: ${ticketChannel.name}
`; - html += `Message: ${msgs.size} Messages


`; - - msgs.forEach((msg) => { - if (msg.content) { - html += `User: ${msg.author.tag}
`; - html += `Message: ${msg.content}
`; - html += `-----

`; - } - }); - - logChannel.send({ embeds: [logEmbed] }).catch((err) => { - interaction.reply(err); - }); - - let file = new Discord.MessageAttachment( - Buffer.from(html), - `${name}.html` - ); - logChannel - .send({ embeds: [logEmbed], files: [file] }) - .catch((err) => { - interaction.reply(err); - }); - - interaction.channel.delete().catch((error) => { - if ( - error.code !== - Discord.Constants.APIErrors.UNKNOWN_CHANNEL - ) { - console.error( - "Failed to delete the interaction:", - error - ); - } - }); - }); - }); - }); - }) - .catch(() => { - interaction - .followUp({ - content: "The request to close the ticket has timed out.", - }) - .then((m2) => setTimeout(() => interaction.channel.delete(3000))); - }); - } - - if (!supportbot.CloseConfirmation) { - let logChannel = - interaction.guild.channels.cache.find( - (channel) => channel.name === supportbot.TranscriptLog - ) || - interaction.guild.channels.cache.find( - (channel) => channel.id === supportbot.TranscriptLog - ); - let user = interaction.user; - let reason = - (await interaction.options.getString("reason")) || - "No Reason Provided."; - - let name = interaction.channel.name; - let ticketChannel = interaction.channel; - - interaction - .reply(`**${supportbot.ClosingTicket}**`) - - .then(() => { - const logEmbed = new Discord.MessageEmbed() - .setTitle(supportbot.TranscriptTitle) - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter) - .addField("Closed By", interaction.user.tag) - .addField("Reason", reason); - - interaction.channel.interactions - .fetch({ limit: 100 }) - .then((msgs) => { - let html = ""; - - msgs = msgs.sort( - (a, b) => a.createdTimestamp - b.createdTimestamp - ); - html += ``; - html += `Server Name: ${interaction.guild.name}
`; - html += `Ticket: ${ticketChannel.name}
`; - html += `Message: ${msgs.size} Messages


`; - - msgs.forEach((msg) => { - if (msg.content) { - html += `User: ${msg.author.tag}
`; - html += `Message: ${msg.content}
`; - html += `-----

`; - } - }); - - logChannel.send({ embeds: [logEmbed] }).catch((err) => { - interaction.reply(err); - }); - - let file = new Discord.MessageAttachment( - Buffer.from(html), - `${name}.html` - ); - logChannel - .send({ embeds: [logEmbed], files: [file] }) - .catch((err) => { - interaction.reply(err); - }); - - interaction.channel.delete().catch((error) => { - if ( - error.code !== Discord.Constants.APIErrors.UNKNOWN_CHANNEL - ) { - console.error("Failed to delete the interaction:", error); - } - }); - }); - }) - .catch(() => { - interaction - .followUp({ - content: "The request to close the ticket has timed out.", - }) - .then((m2) => setTimeout(() => interaction.channel.delete(3000))); - }); - } - }, -}); diff --git a/commands/remove.js b/commands/remove.js deleted file mode 100644 index d062584..0000000 --- a/commands/remove.js +++ /dev/null @@ -1,95 +0,0 @@ -// SupportBot | Emerald Services -// Ticket Remove Command - -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 Command = require("../Structures/Command.js"); - -async function asyncForEach(array, callback) { - for (let index = 0; index < array.length; index++) { - await callback(array[index], index, array); - } -} - -module.exports = new Command({ - name: cmdconfig.TicketRemove, - description: cmdconfig.TicketRemoveDesc, - slashCommandOptions: [ - { - name: "user", - description: "User to remove", - type: "USER", - required: true, - }, - ], - permission: "SEND_MESSAGES", - - async run(interaction) { - let SupportStaff = - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.name === supportbot.Staff - ) || - interaction.guild.roles.cache.find( - (SupportTeam) => SupportTeam.id === supportbot.Staff - ); - let Admins = - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.name === supportbot.Admin - ) || - interaction.guild.roles.cache.find( - (AdminUser) => AdminUser.id === supportbot.Admin - ); - - const NoPerms = new Discord.MessageEmbed() - .setTitle("Invalid Permissions!") - .setDescription( - `${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\`` - ) - .setColor(supportbot.WarningColour); - - if ( - interaction.member.roles.cache.has(SupportStaff.id) || - interaction.member.roles.cache.has(Admins.id) - ) { - if (!interaction.channel.name.startsWith(`${supportbot.TicketPrefix}`)) { - const Exists = new Discord.MessageEmbed() - .setTitle("No Ticket Found!") - .setDescription(`${supportbot.NoValidTicket}`) - .setColor(supportbot.WarningColour); - return interaction.reply({ embeds: [Exists] }); - } - - let uMember = interaction.options.getUser("user"); - const UserNotExist = new Discord.MessageEmbed() - .setTitle("User Not Found!") - .setDescription( - `${supportbot.UserNotFound}\n\nTry Again:\`/${cmdconfig.TicketRemove} \`` - ) - .setColor(supportbot.ErrorColour); - - if (!uMember) return interaction.reply({ embeds: [UserNotExist] }); - - interaction.channel.permissionOverwrites.edit(uMember, { - VIEW_CHANNEL: false, - READ_MESSAGE_HISTORY: false, - SEND_MESSAGES: false, - }); - - const Complete = new Discord.MessageEmbed() - .setTitle("User Removed!") - .setDescription(supportbot.RemovedUser.replace(/%user%/g, uMember.id)) - .setTimestamp() - .setColor(supportbot.EmbedColour); - interaction.reply({ embeds: [Complete] }); - } else { - return interaction.reply({ embeds: [NoPerms] }); - } - }, -}); From 84c0905297641db2cba402a06b4f6146d104f516 Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 28 Oct 2021 18:07:43 -0500 Subject: [PATCH 24/26] Update version numbers --- Configs/supportbot.yml | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Configs/supportbot.yml b/Configs/supportbot.yml index d1e9608..1a809a3 100644 --- a/Configs/supportbot.yml +++ b/Configs/supportbot.yml @@ -10,7 +10,7 @@ # Discord Support: https://emeraldsrv.dev/discord # Community Resources: https://emeraldsrv.dev/resources -SupportBot_Version: "7.2" +SupportBot_Version: "7.3" # ------------------------- # General Configuration diff --git a/package-lock.json b/package-lock.json index adbb482..96e00a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "supportbot", - "version": "7.2.0", + "version": "7.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "supportbot", - "version": "7.2.0", + "version": "7.3.0", "license": "MIT", "dependencies": { "discord.js": "^13.2.0", diff --git a/package.json b/package.json index aa20175..6b8cd12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "supportbot", - "version": "7.2.0", + "version": "7.3.0", "description": "SupportBot is an open-sourced support system for discord. It's completely free to use with high amounts of customization to match your own brand.", "main": "index.js", "scripts": { From 02de920cb37353ba87aada925bc32e32d12ce30b Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 28 Oct 2021 18:39:06 -0500 Subject: [PATCH 25/26] Update package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6b8cd12..d7e99f0 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,14 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/1tzemerald/SupportBot.git" + "url": "git+https://github.com/Emerald-Services/SupportBot.git" }, "author": "Emerald Services", "license": "MIT", "bugs": { - "url": "https://github.com/1tzemerald/SupportBot/issues" + "url": "https://github.com/Emerald-Services/SupportBot/issues" }, - "homepage": "https://github.com/1tzemerald/SupportBot#readme", + "homepage": "https://github.com/Emerald-Services/SupportBot#readme", "dependencies": { "discord.js": "^13.2.0", "js-yaml": "^4.1.0" From 31f6b9e08e9d70f97d02ec100163ecaa54e56ac8 Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 28 Oct 2021 19:08:06 -0500 Subject: [PATCH 26/26] 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); - } - } - } - } -});