├── config.json ├── events ├── ready.js └── interactionCreate.js ├── README.md ├── index.js ├── package.json ├── LICENSE ├── handler └── index.js ├── SlashCommands └── info │ ├── panel.js │ └── close.js └── .gitignore /config.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "token": "", 4 | "prefix": "!", 5 | "mongooseConnectionString": "" 6 | } -------------------------------------------------------------------------------- /events/ready.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | 3 | client.on("ready", () => 4 | console.log(`${client.user.tag} is up and ready to go!`) 5 | ); 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord.js-Tickets-Dropdown 2 | 3 | ## ReadMe 4 | 5 | # How to Install: 6 | Run *npm i* into your folder where you have cloned 7 | Run *node .* to start the bot! 8 | 9 | 10 | # THIS PROJECT IS SPONSORED BY: 11 | [CoreFire](https://corefire.nl) A good and cheap minecraft hosting! 12 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { Client, Collection } = require("discord.js"); 2 | 3 | const client = new Client({ 4 | intents: 32767, 5 | }); 6 | module.exports = client; 7 | 8 | // Global Variables 9 | client.commands = new Collection(); 10 | client.slashCommands = new Collection(); 11 | client.config = require("./config.json"); 12 | 13 | // Initializing the project 14 | require("./handler")(client); 15 | 16 | client.login(client.config.token); 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "djs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "test": "nodemon index.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "discord.js": "^13.2.0", 15 | "glob": "^7.1.7", 16 | "mongoose": "^6.0.2" 17 | } 18 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 CorwinDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /handler/index.js: -------------------------------------------------------------------------------- 1 | const { glob } = require("glob"); 2 | const { promisify } = require("util"); 3 | const { Client } = require("discord.js"); 4 | const mongoose = require("mongoose"); 5 | 6 | const globPromise = promisify(glob); 7 | 8 | /** 9 | * @param {Client} client 10 | */ 11 | module.exports = async (client) => { 12 | // Commands 13 | const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`); 14 | commandFiles.map((value) => { 15 | const file = require(value); 16 | const splitted = value.split("/"); 17 | const directory = splitted[splitted.length - 2]; 18 | 19 | if (file.name) { 20 | const properties = { directory, ...file }; 21 | client.commands.set(file.name, properties); 22 | } 23 | }); 24 | 25 | // Events 26 | const eventFiles = await globPromise(`${process.cwd()}/events/*.js`); 27 | eventFiles.map((value) => require(value)); 28 | 29 | // Slash Commands 30 | const slashCommands = await globPromise( 31 | `${process.cwd()}/SlashCommands/*/*.js` 32 | ); 33 | 34 | const arrayOfSlashCommands = []; 35 | slashCommands.map((value) => { 36 | const file = require(value); 37 | if (!file?.name) return; 38 | client.slashCommands.set(file.name, file); 39 | 40 | if (["MESSAGE", "USER"].includes(file.type)) delete file.description; 41 | arrayOfSlashCommands.push(file); 42 | }); 43 | client.on("ready", async () => { 44 | // Register for a single guild 45 | await client.guilds.cache 46 | .get("905147626104717353") 47 | .commands.set(arrayOfSlashCommands); 48 | 49 | // Register for all the guilds the bot is in 50 | // await client.application.commands.set(arrayOfSlashCommands); 51 | }); 52 | 53 | // mongoose 54 | const { mongooseConnectionString } = require('../config.json') 55 | if (!mongooseConnectionString) return; 56 | 57 | mongoose.connect(mongooseConnectionString).then(() => console.log('Connected to mongodb')); 58 | }; 59 | -------------------------------------------------------------------------------- /SlashCommands/info/panel.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageActionRow, MessageSelectMenu, MessageEmbed } = require("discord.js"); 2 | 3 | module.exports = { 4 | name: "panel", 5 | description: "returns websocket ping", 6 | type: 'CHAT_INPUT', 7 | /** 8 | * 9 | * @param {Client} client 10 | * @param {CommandInteraction} interaction 11 | * @param {String[]} args 12 | */ 13 | run: async (client, interaction, args) => { 14 | await interaction.deferReply({ ephemeral: false }).catch(() => {}); 15 | 16 | const embed = new MessageEmbed() 17 | .setTitle("Tickets") 18 | .setColor("#FF0000") 19 | .setDescription("Choose below an option to get help!") 20 | const row = new MessageActionRow() 21 | .addComponents( 22 | new MessageSelectMenu() 23 | .setCustomId('Tickets') 24 | .setPlaceholder('Nothing selected') 25 | .setMinValues(1) 26 | .setMaxValues(1) 27 | .addOptions([ 28 | { 29 | label: 'Support', 30 | description: 'Get support!', 31 | value: 'Support', 32 | emoji: "💳" 33 | }, 34 | { 35 | label: 'Work', 36 | description: 'Become an worker!', 37 | value: 'Work', 38 | emoji: "📝" 39 | }, 40 | { 41 | label: 'Report', 42 | description: 'Report someone', 43 | value: 'Report', 44 | emoji: "📢" 45 | }, 46 | { 47 | label: 'SOS', 48 | description: 'Other question?', 49 | value: 'Sos', 50 | emoji: "🆘" 51 | }, 52 | ]), 53 | ); 54 | 55 | await interaction.followUp({ components: [row], embeds: [embed] }); 56 | }, 57 | }; 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /SlashCommands/info/close.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageActionRow, MessageSelectMenu, MessageEmbed } = require("discord.js"); 2 | 3 | 4 | 5 | module.exports = { 6 | name: "close", 7 | description: "returns websocket ping", 8 | type: 'CHAT_INPUT', 9 | /** 10 | * 11 | * @param {Client} client 12 | * @param {CommandInteraction} interaction 13 | * @param {String[]} args 14 | */ 15 | run: async (client, interaction, args) => { 16 | 17 | var CloseEmbed = new MessageEmbed() 18 | .setColor("RED") 19 | .setDescription("This isn't a ticket!") 20 | if(interaction.channel.name.includes("│💳・order-" )){ 21 | await interaction.deferReply({ ephemeral: false }).catch(() => {}); 22 | CloseEmbed.setDescription("This ticket will be close soon") 23 | interaction.followUp({embeds: [CloseEmbed]}) 24 | setTimeout(function () { 25 | interaction.channel.delete() 26 | }, 10000); 27 | }else if(interaction.channel.name.includes("│🎫・report-")){ 28 | await interaction.deferReply({ ephemeral: false }).catch(() => {}); 29 | CloseEmbed.setDescription("This ticket will be close soon") 30 | interaction.followUp({embeds: [CloseEmbed]}) 31 | setTimeout(function () { 32 | interaction.channel.delete() 33 | }, 10000); 34 | }else if(interaction.channel.name.includes("│🎫・sos-")){ 35 | await interaction.deferReply({ ephemeral: false }).catch(() => {}); 36 | CloseEmbed.setDescription("This ticket will be close soon") 37 | interaction.followUp({embeds: [CloseEmbed]}) 38 | setTimeout(function () { 39 | interaction.channel.delete() 40 | }, 10000); 41 | } else if(interaction.channel.name.includes("│📝・application-")){ 42 | await interaction.deferReply({ ephemeral: false }).catch(() => {}); 43 | CloseEmbed.setDescription("This ticket will be close soon") 44 | interaction.followUp({embeds: [CloseEmbed]}) 45 | setTimeout(function () { 46 | interaction.channel.delete() 47 | }, 10000); 48 | }else{ 49 | await interaction.deferReply({ ephemeral: true }).catch(() => {}); 50 | interaction.followUp({embeds: [CloseEmbed]}) 51 | 52 | } 53 | 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /events/interactionCreate.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | const ordercat = "918221810598838312" 3 | const shopteam = "918761808515432499" 4 | const employee = "918761785983655976" 5 | const { Permissions, MessageButton, MessageActionRow, MessageEmbed } = require("discord.js") 6 | 7 | 8 | client.on("interactionCreate", async (interaction) => { 9 | // Slash Command Handling 10 | if (interaction.isCommand()) { 11 | 12 | const cmd = client.slashCommands.get(interaction.commandName); 13 | if (!cmd) 14 | return interaction.followUp({ content: "An error has occured " }); 15 | 16 | const args = []; 17 | 18 | for (let option of interaction.options.data) { 19 | if (option.type === "SUB_COMMAND") { 20 | if (option.name) args.push(option.name); 21 | option.options?.forEach((x) => { 22 | if (x.value) args.push(x.value); 23 | }); 24 | } else if (option.value) args.push(option.value); 25 | } 26 | interaction.member = interaction.guild.members.cache.get(interaction.user.id); 27 | 28 | cmd.run(client, interaction, args); 29 | } 30 | 31 | // Context Menu Handling 32 | if (interaction.componentType === "SELECT_MENU") { 33 | if (interaction.values[0] === "Support") { 34 | 35 | 36 | const channel = await interaction.guild.channels.create("│💳・support-" + interaction.user.username, { 37 | type: "GUILD_TEXT", 38 | }); 39 | 40 | await channel.setParent(ordercat) 41 | await channel.permissionOverwrites.create(interaction.guild.id, { VIEW_CHANNEL: false }); 42 | await channel.permissionOverwrites.create(interaction.user.id, { VIEW_CHANNEL: true, CREATE_INSTANT_INVITE: true, SEND_MESSAGES: true, ATTACH_FILES: true, CONNECT: true, ADD_REACTIONS: true, READ_MESSAGE_HISTORY: true }) 43 | await channel.permissionOverwrites.create(interaction.guild.roles.cache.find(x => x.id === employee), { 44 | VIEW_CHANNEL: true, 45 | CREATE_INSTANT_INVITE: false, 46 | SEND_MESSAGES: true, 47 | ATTACH_FILES: true, 48 | CONNECT: true, 49 | ADD_REACTIONS: true, 50 | READ_MESSAGE_HISTORY: true, 51 | }); 52 | 53 | 54 | await interaction.deferReply({ ephemeral: true }).catch(() => { }); 55 | 56 | interaction.followUp(`You ticket is made: <#${channel.id}>`); 57 | 58 | var ticketEmbedBestellen = new MessageEmbed() 59 | .setTitle(`Hi ${interaction.user.username}`) 60 | .setColor("ORANGE") 61 | .setDescription("How can you help you?") 62 | .addField("Reason: Support", "Made with ❤️ by [Corwin](https://corwindev.nl)") 63 | await channel.send({ content: `<@${interaction.user.id}>`, embeds: [ticketEmbedBestellen] }) 64 | 65 | 66 | 67 | 68 | 69 | } else if (interaction.values[0] === "Work") { 70 | 71 | 72 | const channel = await interaction.guild.channels.create("│📝・application-" + interaction.user.username, { 73 | type: "GUILD_TEXT", 74 | }); 75 | 76 | await channel.setParent(ordercat) 77 | await channel.permissionOverwrites.create(interaction.guild.id, { VIEW_CHANNEL: false }); 78 | await channel.permissionOverwrites.create(interaction.user.id, { VIEW_CHANNEL: true, CREATE_INSTANT_INVITE: true, SEND_MESSAGES: true, ATTACH_FILES: true, CONNECT: true, ADD_REACTIONS: true, READ_MESSAGE_HISTORY: true }) 79 | await channel.permissionOverwrites.create(interaction.guild.roles.cache.find(x => x.id === employee), { 80 | VIEW_CHANNEL: true, 81 | CREATE_INSTANT_INVITE: false, 82 | SEND_MESSAGES: true, 83 | ATTACH_FILES: true, 84 | CONNECT: true, 85 | ADD_REACTIONS: true, 86 | READ_MESSAGE_HISTORY: true, 87 | }); 88 | 89 | 90 | await interaction.deferReply({ ephemeral: true }).catch(() => { }); 91 | 92 | interaction.followUp(`You ticket is made: <#${channel.id}>`); 93 | var ticketEmbedSolliteren = new MessageEmbed() 94 | .setTitle(`Hi ${interaction.user.username}`) 95 | .setColor("GREEN") 96 | .setDescription("For what do you want to apply?") 97 | .addField("Reason for ticket 📝 • Application", "Made with ❤️ by [Corwin](https://corwindev.nl)") 98 | channel.send({ content: `<@${interaction.user.id}>`, embeds: [ticketEmbedSolliteren] }) 99 | 100 | 101 | } else if (interaction.values[0] === "Sos") { 102 | 103 | 104 | const channel = await interaction.guild.channels.create("│🎫・sos-" + interaction.user.username, { 105 | type: "GUILD_TEXT", 106 | }); 107 | 108 | await channel.setParent(ordercat) 109 | await channel.permissionOverwrites.create(interaction.guild.id, { VIEW_CHANNEL: false }); 110 | await channel.permissionOverwrites.create(interaction.user.id, { VIEW_CHANNEL: true, CREATE_INSTANT_INVITE: true, SEND_MESSAGES: true, ATTACH_FILES: true, CONNECT: true, ADD_REACTIONS: true, READ_MESSAGE_HISTORY: true }) 111 | await channel.permissionOverwrites.create(interaction.guild.roles.cache.find(x => x.id === employee), { 112 | VIEW_CHANNEL: true, 113 | CREATE_INSTANT_INVITE: false, 114 | SEND_MESSAGES: true, 115 | ATTACH_FILES: true, 116 | CONNECT: true, 117 | ADD_REACTIONS: true, 118 | READ_MESSAGE_HISTORY: true, 119 | }); 120 | 121 | 122 | await interaction.deferReply({ ephemeral: true }).catch(() => { }); 123 | 124 | interaction.followUp(`You ticket is made: <#${channel.id}>`); 125 | var ticketEmbedSolliteren = new MessageEmbed() 126 | .setTitle(`Hi ${interaction.user.username}`) 127 | .setColor("GREEN") 128 | .setDescription("Your question is not in one of our general options, Could you please tell us what your question is? Then one of our employees will help you as soon as possible!") 129 | .addField("Reason for ticket: SOS ", "Made with ❤️ by [Corwin](https://corwindev.nl)") 130 | channel.send({ content: `<@${interaction.user.id}>`, embeds: [ticketEmbedSolliteren] }) 131 | 132 | 133 | 134 | } else if (interaction.values[0] === "Report") { 135 | 136 | 137 | const channel = await interaction.guild.channels.create("│🎫・report-" + interaction.user.username, { 138 | type: "GUILD_TEXT", 139 | }); 140 | 141 | await channel.setParent(ordercat) 142 | await channel.permissionOverwrites.create(interaction.guild.id, { VIEW_CHANNEL: false }); 143 | await channel.permissionOverwrites.create(interaction.user.id, { VIEW_CHANNEL: true, CREATE_INSTANT_INVITE: true, SEND_MESSAGES: true, ATTACH_FILES: true, CONNECT: true, ADD_REACTIONS: true, READ_MESSAGE_HISTORY: true }) 144 | await channel.permissionOverwrites.create(interaction.guild.roles.cache.find(x => x.id === employee), { 145 | VIEW_CHANNEL: true, 146 | CREATE_INSTANT_INVITE: false, 147 | SEND_MESSAGES: true, 148 | ATTACH_FILES: true, 149 | CONNECT: true, 150 | ADD_REACTIONS: true, 151 | READ_MESSAGE_HISTORY: true, 152 | }); 153 | 154 | 155 | await interaction.deferReply({ ephemeral: true }).catch(() => { }); 156 | 157 | interaction.followUp(`You ticket is made: <#${channel.id}>`); 158 | var ticketEmbedSolliteren = new MessageEmbed() 159 | .setTitle(`Hi ${interaction.user.username}`) 160 | .setColor("GREEN") 161 | .setDescription("Please say your reason and who you want to report") 162 | .addField("Reason for ticket Report", "Made with ❤️ by [Corwin](https://corwindev.nl)") 163 | channel.send({ content: `<@${interaction.user.id}>`, embeds: [ticketEmbedSolliteren] }) 164 | 165 | 166 | 167 | } else { 168 | console.log(interaction) 169 | } 170 | 171 | } 172 | }); 173 | --------------------------------------------------------------------------------