diff --git a/README.md b/README.md index 6316c59..79c6b24 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This is an open-source discord ticket bot, you can configure it and it comes wit Open Ticket logo -[![q&a](https://img.shields.io/badge/Q&A-click%20here-blue.svg?style=flat-square)](./TEMPDOCS.md) +[![q&a](https://img.shields.io/badge/Q&A-click%20here-blue.svg?style=flat-square)](https://www.github.com/DJj123dj/open-ticket/wiki/q&a) ## features - discord interaction buttons @@ -27,8 +27,8 @@ This is an open-source discord ticket bot, you can configure it and it comes wit - uses discord.js 13 - configure your own ticket options - remove credits if you want -- up to 6 tickets at the same time -- change all bot messages +- unlimited tickets at the same time +- localisation in +5 languages (soon™) ## installation **You need `node.js 16` to run this project!** @@ -50,7 +50,7 @@ if there are any errors, you can open an **issue on github** or **contact me in ### config Our config documentation is moved to another file: -[click here to view](./TEMPDOCS.md) +[click here to view](https://www.github.com/DJj123dj/open-ticket/wiki/config-v2.0.0) ### intents & permissions In the discord developer portal in the "bot" panel you will find 3 switches under the title "Gateaway Intents". The following switches should always be turned on @@ -64,6 +64,6 @@ You can also configure your own permissions _v2.0.0 unstable_ -changelog: [click here](./TEMPDOCS.md) +changelog: [click here](https://www.github.com/DJj123dj/open-ticket/wiki/Changelog) © 2022 - DJdj Development | [website](https://www.dj-dj.be) | [discord](https://discord.com/invite/26vT9wt3n3) \ No newline at end of file diff --git a/core/reactionRoles.js b/core/reactionRoles.js new file mode 100644 index 0000000..0e288b4 --- /dev/null +++ b/core/reactionRoles.js @@ -0,0 +1,56 @@ +const discord = require('discord.js') +const bot = require('../index') +const client = bot.client +const config = bot.config + +const storage = bot.storage + +module.exports = async () => { + const chalk = await (await import("chalk")).default + + client.on("interactionCreate",(interaction) => { + if (!interaction.isButton()) return + if (!interaction.customId.startsWith("newR")) return + + interaction.deferUpdate() + + const optionid = interaction.customId.split("newR")[1] + if (!optionid){ + interaction.reply({content:"This button doesn't exist anymore"}) + return + } + + try { + + const option = require("./utils/getButton").getOption(optionid) + /**@type {"add"|"remove"|"add&remove"} */ + const mode = option.mode + const user = interaction.member + + if (mode == "add"){ + option.roles.forEach((role) => { + interaction.guild.members.cache.find(u => u.id == user.id).roles.add(role) + console.log("[system] added role",role,"to",user.user.tag) + }) + }else if (mode == "remove"){ + option.roles.forEach((role) => { + interaction.guild.members.cache.find(u => u.id == user.id).roles.remove(role) + console.log("[system] removed role",role,"from",user.user.tag) + }) + }else if (mode == "add&remove"){ + option.roles.forEach((role) => { + if (interaction.guild.members.cache.find(u => u.id == user.id).roles.cache.has(role)){ + interaction.guild.members.cache.find(u => u.id == user.id).roles.remove(role) + console.log("[system] removed role",role,"from",user.user.tag) + }else { + interaction.guild.members.cache.find(u => u.id == user.id).roles.add(role) + console.log("[system] added role",role,"to",user.user.tag) + } + }) + } + + }catch{ + interaction.reply({ephemeral:true,content:"Something went wrong! Contact the owner of this bot for more information"}) + } + }) +} \ No newline at end of file diff --git a/index.js b/index.js index f4f88f7..d9c8b83 100644 --- a/index.js +++ b/index.js @@ -65,6 +65,7 @@ if (process.argv[2] != "slash"){ require('./core/ticketOpener')() require("./core/ticketCloser").runThis() require("./core/closebuttons")() + require("./core/reactionRoles")() /** * We need: