diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e1da6ae..0000000 --- a/.gitignore +++ /dev/null @@ -1,76 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless - -# FuseBox cache -.fusebox/ diff --git a/LICENSE b/LICENSE index 4cc78e0..400c4d6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Emerald Services +Copyright (c) 2020 ItzEmerald Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 9a52e6b..2743f94 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,24 @@ -

SupportBot

-

Created by Emerald SRV's Developer Team

-

SupportBot is a free self-hosted discord that is developed/designed to help control and manage the support that takes place throughout your discord server(s). SupportBot has been going around since late-2018 and it's still being constantly, updated and supported today. Alongside the core features of SupportBot which is support related features such as tickets etc.. we also allow additional addons which are made by both 3rd-party and official developers. If something goes wrong with SupportBot you can simply come to our discord server and contact us. We will be happy to help. Also! if anyone ever tells you that "nothing is free" then tell them to think again. Sometimes you just have to look a little harder to find what you want.

-Version 5.2 -
+ ``` + _________ __ __________ __ + / _____/__ ________ ______ ____________/ |\______ \ _____/ |_ + \_____ \| | \____ \\____ \ / _ \_ __ \ __\ | _// _ \ __\ + / \ | / |_> > |_> > <_> ) | \/| | | | ( <_> ) | + /_______ /____/| __/| __/ \____/|__| |__| |______ /\____/|__| + \/ |__| |__| \/ + + SupportBot version 6.0 + Created by Emerald Services + + The #1 self-hosted discord ticket bot +``` + +## UPPORTBOT SUPPORTED VERSIONS + +| SupportBot | Status | Supported | +|------------|-----------|--------------| +| 1.x | ❌ | Discontinued | +| 2.x | ❌ | Discontinued | +| 3.x | ❌ | Discontinued | +| 4.x | ✔️ | Previous | +| 5.x | ✔️ | Current | +| 6.x | ⚠️ | Under Development | diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c419263..0000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-cayman \ No newline at end of file diff --git a/commands/add.js b/commands/add.js deleted file mode 100644 index e4e3f54..0000000 --- a/commands/add.js +++ /dev/null @@ -1,52 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Add - -const Discord = require("discord.js"); -const bot = new Discord.Client() - -const fs = require("fs") -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Add_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.StaffRole); - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - const outsideticket = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) - .setColor(supportbot.WarningColour); - if (!message.channel.name.startsWith(`${supportbot.Ticket_Channel_Name}-`)) return message.channel.send({embed: outsideticket}); - - let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); - - const cantfinduser = new Discord.MessageEmbed() - .setTitle("Invalid User!") - .setDescription(`:warning: This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.Add_Command} \``) - .setColor(supportbot.WarningColour); - if(!rUser) return message.channel.send({embed: cantfinduser}); - - message.channel.updateOverwrite(rUser, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - - const useradded = new Discord.MessageEmbed() - .setColor(supportbot.SuccessColour) - .setTitle("User Added") - .setDescription(`👍 ${rUser} has been added to this ticket`) - .setTimestamp(); - message.channel.send({embed: useradded}); - -}; - -exports.help = { - name: supportbot.Add_Command, -}; diff --git a/commands/announce.js b/commands/announce.js index 91c6701..f41df48 100644 --- a/commands/announce.js +++ b/commands/announce.js @@ -1,55 +1,65 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Announce (including @everyone) +// SupportBot 6.0, Created by Emerald Services +// Links Command const Discord = require("discord.js"); -const bot = new Discord.Client(); +const fs = require("fs"); -const fs = require("fs") const yaml = require('js-yaml'); - +const { execute } = require("./help"); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); -exports.run = (bot, message, args) => { +module.exports = { + name: supportbot.AnnounceCommand, - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Announcement_Command}`); + execute(message, args) { + + let locateChannel = message.guild.channels.cache.find(AnnouncementChannel => AnnouncementChannel.name === supportbot.AnnouncementChannel); + + const errornochannel = new Discord.MessageEmbed() + .setTitle("SupportBot Error!") + .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.AnnouncementChannel}\`\n\nError Code: \`SB-03\``) + .setColor(supportbot.ErrorColour); + + if(!locateChannel) return message.channel.send({ embed: errornochannel }); + + let serverAdmins = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Admin); + + const rolerequired = new Discord.MessageEmbed() + .setTitle("SupportBot Error!") + .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.Admin}\`\n\nError Code: \`SB-02\``) + .setColor(supportbot.ErrorColour); + if (!message.member.roles.cache.has(serverAdmins.id)) return message.reply({embed: rolerequired}); + + + const embed = new Discord.MessageEmbed() + .setDescription(`> **${supportbot.AnnouncementStarter}**`) + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: embed }); + + let announcement = [] + message.channel.awaitMessages(response => response.content.length > 2, { + max: 1, + time: 500000, + errors: ['time'], + }).then((collected) => { + announcement.push(collected.map(r => r.content)); + + const AnnouncementEmbed = new Discord.MessageEmbed() + .setTitle(supportbot.AnnouncementTitle) + .setThumbnail(supportbot.AnnouncementIcon) + .setDescription(announcement) + .setColor(supportbot.EmbedColour) + .setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL()); + + locateChannel.send({ embed: AnnouncementEmbed }).then(async function(msg) { + const AnnouncementComplete = new Discord.MessageEmbed() + .setColor(supportbot.SuccessColour) + .setDescription(`:white_check_mark: You have successfully created an announcement. <#${locateChannel.id}>`) + message.channel.send({ embed: AnnouncementComplete }) + }) + + }); + + } - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.StaffRole); - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - const embed = new Discord.MessageEmbed() - .setTitle(`${supportbot.Announcement_Title}`) - .setDescription(args.join(" ")) - .setTimestamp() - .setColor(supportbot.EmbedColour) - .setFooter(`${message.author.username}#${message.author.discriminator}`, message.author.displayAvatarURL) - - let locateChannel = message.guild.channels.cache.find(LocateChannel => LocateChannel.name === `${supportbot.Announcement_Channel}`) - - const errornochannel = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.Announcement_Channel}\`\n\nError Code: \`SB-03\``) - .setColor(supportbot.ErrorColour); - if(!locateChannel) return message.channel.send(errornochannel); - - locateChannel.send(supportbot.everyone).then((msg) => { - locateChannel.send(embed); - }); - - - const AccSuccessEmbed = new Discord.MessageEmbed() - .setTitle("Announcement Created") - .setDescription(`👍 Successfully sent your announcement to <#${locateChannel.id}>`) - .setColor(supportbot.EmbedColour) - message.channel.send({embed: AccSuccessEmbed}); - -} - -exports.help = { - name: supportbot.Announcement_Command, -} +}; \ No newline at end of file diff --git a/commands/close.js b/commands/close.js index cbcf82c..2a5f340 100644 --- a/commands/close.js +++ b/commands/close.js @@ -1,116 +1,18 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Close +// SupportBot 6.0, Created by Emerald Services +// Links Command const Discord = require("discord.js"); -const bot = new Discord.Client(); - const fs = require("fs"); -const yaml = require('js-yaml'); +const yaml = require('js-yaml'); +const { execute } = require("./help"); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); -/** - * @param {Discord.Message} message - */ +module.exports = { + name: "bob", -exports.run = (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Close_Command}`); - - if ( !message.channel.name.startsWith( `${supportbot.Ticket_Channel_Name}-` ) ) { - const embed = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) - .setColor(supportbot.WarningColour); - message.channel.send(embed); - return; + execute(message, args) { + + message.channel.delete() } - - const closeRequestEmbed = new Discord.MessageEmbed() - .setDescription(`**${supportbot.Ticket_Closure}**`) - .addField("Please confirm by repeating the following word..", `||**${supportbot.Closure_Confirm_Word}**||`) - .setFooter("Your request will be avoided in 20 seconds") - .setColor(supportbot.EmbedColour) - - - message.channel.send(closeRequestEmbed).then( m => { - message.channel.awaitMessages( response => response.content.toLowerCase() === supportbot.Closure_Confirm_Word, { - max: 1, - time: 20000, - errors: [ 'time' ], - - } ).then( collected => { - let logChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.Transcript_Log); - - let user = message.author; - - let reason = args.join(" ") || "No reason provided."; - - let name = message.channel.name; - let ticketChannel = message.channel; - - message.channel.send(`**${supportbot.Ticket_Closing}**`) - .then(() => { - const logEmbed = new Discord.MessageEmbed() - .setTitle(supportbot.Transcript_Title) - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter) - .addField("Ticket Author", user) - .addField("Closed By", message.author.tag) - .addField("Reason", reason); - - message.channel.messages.fetch({ limit: 100 }) - .then( msgs => { - let txt = ''; - - msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp ); - - txt += `${message.guild.name}\n`; - txt += `#${ticketChannel.name}\n`; - txt += `${msgs.size} messages\n\n\n`; - - msgs.forEach( msg => { - if ( msg.content ) { - txt += `----- ${msg.author.tag} at ${msg.createdAt}\n`; - txt += `${msg.content}\n`; - txt += `-----\n\n`; - } - } ); - - // message.author.send( `A transcript has been generated for the ticket you closed.` ); - // message.author.send( new Discord.Attachment( Buffer.from( txt ), `${name}.txt` ) ); - - logChannel.send(logEmbed).catch(err => { - message.reply(err) - }) - logChannel.send( new Discord.MessageAttachment( Buffer.from( txt ), `${name}.txt` ) ); - - message.channel.delete(); - - // message.channel.messages.fetch( { limit: 100, before: msgs.last().id } ) - - // .then( msg => { - // const merged = msgs.concat( msg ); - // const output = merged.reduce( ( out, msg ) => { - // out += `[${message.createdAt}] ${message.author.tag}: ${message.cleanContent ? message.cleanContent.replace( /\n/g, '\r\n' ) : ''}\r\n`; - // return out; - // }, '' ); - - // log.send( { files: [ { attachment: Buffer.from( output, 'utf8' ), name: `${name}.txt` } ] } ).then( c.delete() ).catch( console.error ); // sends the file to logs - // return log.send( embed1 ).catch( console.error ); - // } ) - }); - }) - - }).catch( () => { - m.edit('The request to close the ticket has timed out.').then( m2 => m2.delete( 3000 ) ); - }); - }); - -} - - -exports.help = { - name: supportbot.Close_Command, -} +}; \ No newline at end of file diff --git a/commands/forceclose.js b/commands/forceclose.js deleted file mode 100644 index c818431..0000000 --- a/commands/forceclose.js +++ /dev/null @@ -1,70 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Forceclose - -const Discord = require("discord.js"); -const bot = new Discord.Client() - -const fs = require("fs") -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = async (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Forceclose_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.StaffRole); - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - const outsideticket = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) - .setColor(supportbot.WarningColour); - if (!message.channel.name.startsWith(`${supportbot.Ticket_Channel_Name}-`)) return message.channel.send({embed: outsideticket}); - - const log = message.guild.channels.cache.find(channel => channel.name === supportbot.Transcript_Log) - const uID = message.author - const reason = args.join(" ") || "No Reason Provided."; - const name = message.channel.name; - const c = message.channel; - - message.channel.send(`Your ticket is currently closing`) - - .then(() => { - - const embed1 = new Discord.MessageEmbed() - .setTitle(supportbot.Transcript_Title) - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter) - .addField("Ticket Author", uID) - .addField("Closed By", message.author.tag) - .addField("Reason", reason) - message.channel.messages.fetch({ limit: 100 }) - - .then(msgs => { - message.channel.messages.fetch({ limit: 100, before: msgs.last().id }) - - .then(msg => { - const merged = msgs.concat(msg); - const output = merged.reduce((out, msg) => { - out += `[${message.createdAt}] ${message.author.tag}: ${message.cleanContent ? message.cleanContent.replace(/\n/g, '\r\n') : ''}\r\n`; - return out; - }, ''); - - log.send({ files: [{ attachment: Buffer.from(output, 'utf8'), name: `${name}.txt` }] }).then(c.delete()).catch(console.error); // sends the file to logs - return log.send(embed1).catch(console.error); - }) - }); -}); - -} - -exports.help = { - name: supportbot.Forceclose_Command, -} diff --git a/commands/help.js b/commands/help.js index 51eed84..7cac1a5 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,52 +1,49 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Help +// SupportBot 6.0, Created by Emerald Services +// Help Command const Discord = require("discord.js"); -const bot = new Discord.Client() +const fs = require("fs"); -const fs = require("fs") const yaml = require('js-yaml'); - const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); -exports.run = (bot, message, args) => { +module.exports = { + name: supportbot.HelpCommand, - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Help_Command}`); + execute(message, args) { + let generalCommands = ""; + generalCommands += `**${supportbot.Prefix}${supportbot.HelpCommand}** Lists all the bot commands\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.LinksCommand}** Get some important links\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.SuggestCommand}** Create a new suggestion\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.PingCommand}** Check bot's latency\n`; + + let supportCommands = ""; + supportCommands += `**${supportbot.Prefix}${supportbot.NewTicket} [reason]** Create a support ticket\n` + supportCommands += `**${supportbot.Prefix}${supportbot.CloseTicket} [reason]** Close your support ticket\n` + + let staffCommands = ""; + staffCommands += `**${supportbot.Prefix}${supportbot.RenameTicket} ** Rename a valid support ticket\n` + staffCommands += `**${supportbot.Prefix}${supportbot.AddUser} ** Add a user to a valid support ticket\n` + staffCommands += `**${supportbot.Prefix}${supportbot.RemoveUser} ** Remove a user from a valid support ticket\n` + + let adminCommands = ""; + adminCommands += `**${supportbot.Prefix}${supportbot.AnnounceCommand}** Create a new server announcement\n` + adminCommands += `**${supportbot.Prefix}${supportbot.SayCommand}** Send a message as the bot\n` + + const HelpCommandEmbed = new Discord.MessageEmbed() + .setTitle(supportbot.Bot_Name) + .setThumbnail(message.author.displayAvatarURL()) - let userCommands = ""; - userCommands += `**${supportbot.Prefix}${supportbot.Ticket_Command} **: Create a support ticket\n`; - userCommands += `**${supportbot.Prefix}${supportbot.Close_Command}**: Close your support ticket\n`; - userCommands += `**${supportbot.Prefix}${supportbot.Suggest_Command} **: Create a server suggestion\n`; - userCommands += `**${supportbot.Prefix}${supportbot.Report_Command} **: Report a valid user\n`; - userCommands += `**${supportbot.Prefix}${supportbot.Link_Command}**: Get some important links!\n`; - userCommands += `**${supportbot.Prefix}${supportbot.Ping_Command}**: Check the bots ping. Pong!\n`; - - let supportCommands = ""; - supportCommands += `**${supportbot.Prefix}${supportbot.Add_Command} **: Adds a user to a ticket\n`; - supportCommands += `**${supportbot.Prefix}${supportbot.Remove_Command} **: Removes a user from a ticket\n`; - supportCommands += `**${supportbot.Prefix}${supportbot.Forceclose_Command}**: Forceclose a support ticket\n`; - supportCommands += `**${supportbot.Prefix}${supportbot.Rename_Command}**: Rename a support ticket\n`; + .addFields( + { name: '🖥️ General Commands', value: `${generalCommands}\n`, inline: false }, + { name: '🎫 Support Commands', value: `${supportCommands}\n`, inline: false }, + { name: '🔑 Staff Commands', value: `${staffCommands}\n`, inline: false }, + { name: '🔐 Admin Commands', value: `${adminCommands}`, inline: false }, + ) - let staffCommands = ""; - staffCommands += `**${supportbot.Prefix}${supportbot.Announcement_Command} **: Create a bot announcement\n`; - staffCommands += `**${supportbot.Prefix}${supportbot.Say_Command} **: Send a message as the bot\n`; - staffCommands += `**${supportbot.Prefix}${supportbot.Lockchat_Command}**: Lock the chat channel\n`; - staffCommands += `**${supportbot.Prefix}${supportbot.UnLockchat_Command}**: UnLock the chat channel\n`; - staffCommands += `**${supportbot.Prefix}${supportbot.Poll_Command}**: Create a poll\n`; + .setColor(supportbot.EmbedColour) + .setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL()); - const embed = new Discord.MessageEmbed() - .setTitle(supportbot.Bot_Name) - .addField("🟨 User Commands", userCommands) - .addField("🎫 Support Commands", supportCommands) - .addField("🔐 Staff Commands", staffCommands) - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL); - - message.channel.send(embed); - -} - -exports.help = { - name: supportbot.Help_Command, -}; + message.channel.send({ embed: HelpCommandEmbed }); + } +}; \ No newline at end of file diff --git a/commands/links.js b/commands/links.js index f8c8d9d..f17a9c9 100644 --- a/commands/links.js +++ b/commands/links.js @@ -1,36 +1,32 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Links +// SupportBot 6.0, Created by Emerald Services +// Links Command const Discord = require("discord.js"); -const bot = new Discord.Client(); - const fs = require("fs"); -const yaml = require('js-yaml'); +const yaml = require('js-yaml'); +const { execute } = require("./help"); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); -exports.run = ( bot, message, args ) => { +module.exports = { + name: supportbot.LinksCommand, - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Link_Command}`); + execute(message, args) { + + const LinksEmbed = new Discord.MessageEmbed() + .setColor(supportbot.EmbedColour) - let botLinks = supportbot.LINKS; + let botLinks = supportbot.LINKS; + + let links = ''; + + for ( let name in botLinks ) { + links += `[${name}](${botLinks[ name ]})\n`; + }; - let links = ''; + LinksEmbed.addField(supportbot.LinksTitle, links) - for ( let name in botLinks ) { - links += `[${name}](${botLinks[ name ]})\n`; - }; + message.channel.send({ embed: LinksEmbed }); - let embed = new Discord.MessageEmbed() - .setTitle(supportbot.LINKS_TITLE) - .setDescription(links) - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter); - message.channel.send(embed); - -}; - -exports.help = { - name: supportbot.Link_Command, -}; + } +}; \ No newline at end of file diff --git a/commands/lockchat.js b/commands/lockchat.js deleted file mode 100644 index 60bd0e5..0000000 --- a/commands/lockchat.js +++ /dev/null @@ -1,38 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Close - -const Discord = require("discord.js"); -const bot = new Discord.Client(); - -const fs = require("fs"); -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = async(bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Lockchat_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === `${supportbot.StaffRole}`) - let lockedRole = message.guild.roles.cache.find(lc => lc.name === `${supportbot.locked_role}`) - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - message.channel.updateOverwrite(lockedRole, { READ_MESSAGES: false, SEND_MESSAGES: false }); - message.channel.updateOverwrite(staffGroup, { READ_MESSAGES: true, SEND_MESSAGES: true }); - - const lockmsg = new Discord.MessageEmbed() - .setDescription(":white_check_mark: **Chat Locked**") - .setColor(supportbot.EmbedColour) - message.channel.send(lockmsg); - -}; - -exports.help = { - name: supportbot.Lockchat_Command, -}; diff --git a/commands/newticket.js b/commands/newticket.js new file mode 100644 index 0000000..cfd5fb0 --- /dev/null +++ b/commands/newticket.js @@ -0,0 +1,213 @@ +const Discord = require("discord.js"); +const bot = new Discord.Client() + +const fs = require("fs") +const yaml = require('js-yaml'); + +const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); +const TicketNumberID = require('../utils/TicketNumber.js'); + +module.exports = { + name: supportbot.NewTicket, + + execute(message, args) { + console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.NewTicket}!`); + + // Ticket ID + let ticketNumberID = TicketNumberID.pad(message.guild.id); + + // Ticket Subject + const TicketSubject = args.join(" ") || supportbot.NoTicketSubject; + + // Ticket Exists + const TicketExists = new Discord.MessageEmbed() + .setTitle("Ticket Exists!") + .setDescription(":no_entry_sign: This ticket cannot be opened, It already exists!") + .setColor(supportbot.WarningColour) + + if (message.guild.channels.cache.find(SupportTicket => SupportTicket.name === `${supportbot.TicketChannel}-${ticketNumberID}`)) + return message.channel.send({ embed: TicketExists }); + + message.guild.channels.create(`${supportbot.TicketChannel}-${ticketNumberID}`, { + type: "text", + }).then(SupportTicket => { + + let AllUsers = message.guild.roles.cache.find(everyone => everyone.name === '@everyone') + let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) + let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) + + let DeptRole1 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_1}`) + let DeptRole2 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_2}`) + let DeptRole3 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_3}`) + + SupportTicket.updateOverwrite(AllUsers, { + VIEW_CHANNEL: false, + }) + + SupportTicket.updateOverwrite(message.author, { + VIEW_CHANNEL: true, + READ_MESSAGES: true, + SEND_MESSAGES: true, + }) + + SupportTicket.updateOverwrite(SupportStaff, { + VIEW_CHANNEL: true, + READ_MESSAGES: true, + SEND_MESSAGES: true, + }) + + SupportTicket.updateOverwrite(Admins, { + VIEW_CHANNEL: true, + READ_MESSAGES: true, + SEND_MESSAGES: true, + }) + + // Ticket Category + let TicketCategory = message.guild.channels.cache.find(category => category.name === supportbot.TicketCategory) + + if (TicketCategory) { + SupportTicket.setParent(TicketCategory.id) + } else { + if (message.guild.channels.cache.get(supportbot.TicketCategory)) { + SupportTicket.setParent(message.guild.channels.cache.get(supportbot.TicketCategory).id); + } + } + + // Ticket Created, Message Sent + const TicketMessage = new Discord.MessageEmbed() + .setTitle(supportbot.Ticket_Title.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, SupportTicket.id).replace(/%ticketusername%/g, message.member.user.username)) + .setDescription(supportbot.TicketMessage.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, SupportTicket.id).replace(/%ticketusername%/g, message.member.user.username)) + .setColor(supportbot.EmbedColour) + + if (supportbot.TicketSubject === "embed") { + + if (TicketSubject != 'No Reason Provided.') { + TicketMessage.addFields({ name: 'Reason', value: TicketSubject }) + } + + } + + if (supportbot.TicketSubject === "description") { + + if (TicketSubject != 'No Reason Provided.') { + SupportTicket.setTopic(`Reason: ${TicketSubject} - User ID: ${message.author.id} - Ticket: ${SupportTicket.name}`) + } + + } + + if (supportbot.TicketDepartments === true) { + TicketMessage.addFields({ name: 'Departments', value: `${supportbot.DepartmentEmoji_1} **${supportbot.DepartmentTitle_1}**\n${supportbot.DepartmentEmoji_2} **${supportbot.DepartmentTitle_2}**\n${supportbot.DepartmentEmoji_3} **${supportbot.DepartmentTitle_3}**` }) + } + + SupportTicket.send({ embed: TicketMessage }).then( async function(msg) { + + const Emoji_1 = supportbot.DepartmentEmoji_1; + const Emoji_2 = supportbot.DepartmentEmoji_2; + const Emoji_3 = supportbot.DepartmentEmoji_3; + + if (supportbot.TicketDepartments === true) { + msg.react(Emoji_1).then(() => msg.react(Emoji_2)).then(() => msg.react(Emoji_3)) + + const filter = (reaction, user) => { + return [Emoji_1, Emoji_2, Emoji_3].includes(reaction.emoji.name) && user.id !== message.author.id; + } + + setTimeout(async function() { + msg.awaitReactions(filter, { + max: 4, + time: 60000, + errors: ['time'] + }).then(async collected => { + const reaction = collected.first(); + + if (reaction.emoji.name === Emoji_1) { + SupportTicket.updateOverwrite(message.author.id, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + SupportTicket.updateOverwrite(Admins, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + SupportTicket.updateOverwrite(DeptRole1, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + + if (supportbot.AllowStaff === true) { + SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + } + + const Department1 = new Discord.MessageEmbed() + .setTitle(`> Thank for reaching out to the **${supportbot.DepartmentTitle_1} Department**. Please provide us information regarding your query.`) + .setColor(supportbot.EmbedColour) + SupportTicket.send({ embed: Department1 }); + + } + + if (reaction.emoji.name === Emoji_2) { + SupportTicket.updateOverwrite(message.author.id, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + SupportTicket.updateOverwrite(Admins, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + SupportTicket.updateOverwrite(DeptRole2, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + + if (supportbot.AllowStaff === true) { + SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + } + + const Department2 = new Discord.MessageEmbed() + .setTitle(`> Thank for reaching out to the **${supportbot.DepartmentTitle_2} Department**. Please provide us information regarding your query.`) + .setColor(supportbot.EmbedColour) + SupportTicket.send({ embed: Department2 }); + + } + + if (reaction.emoji.name === `${Emoji_3}`) { + SupportTicket.updateOverwrite(message.author.id, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + SupportTicket.updateOverwrite(Admins, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + SupportTicket.updateOverwrite(DeptRole3, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + + if (supportbot.AllowStaff === true) { + SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) + } + + const Department2 = new Discord.MessageEmbed() + .setTitle(`> Thank for reaching out to the **${supportbot.DepartmentTitle_3} Department**. Please provide us information regarding your query.`) + .setColor(supportbot.EmbedColour) + SupportTicket.send({ embed: Department3 }); + + } + + }) + }, supportbot.DepartmentTiming); + + } + + }); + const CreatedTicket = new Discord.MessageEmbed() + .setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, SupportTicket.id).replace(/%ticketusername%/g, message.member.user.username)) + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: CreatedTicket }); + + fs.writeFileSync("./storage/SupportTickets.json", '{\n "ticket": "' + SupportTicket.name + '", \n "id":' + message.author.id + "\n}", (err) => { + if (!err) return; + console.error(err) + }) + + // Ticket Logs + + const errornochannel = new Discord.MessageEmbed() + .setTitle("SupportBot Error!") + .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.TicketLog}\`\n\nError Code: \`SB-03\``) + .setColor(supportbot.ErrorColour); + + const TicketLogs = new Discord.MessageEmbed() + .setTitle("Ticket Log") + .setThumbnail(supportbot.Ticket_Thumbnail) + .addFields( + { name: 'Ticket', value: `<#${SupportTicket.id}>` }, + { name: 'User', value: `<@${message.author.id}>` }, + ) + .setColor(supportbot.EmbedColour) + .setFooter(supportbot.EmbedFooter) + + let locateChannel = message.guild.channels.cache.find(LocateChannel => LocateChannel.name === supportbot.TicketLog) + + if(!locateChannel) return message.channel.send({ embed: errornochannel }); + + locateChannel.send({ embed: TicketLogs }); + }) + + } + +}; diff --git a/commands/ping.js b/commands/ping.js index 4965612..5a6548e 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -1,26 +1,22 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Ping +// SupportBot 6.0, Created by Emerald Services +// Help Command const Discord = require("discord.js"); -const bot = new Discord.Client(); - const fs = require("fs"); -const yaml = require('js-yaml'); +const yaml = require('js-yaml'); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); -exports.run = (bot, message, args) => { +module.exports = { + name: supportbot.PingCommand, - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Ping_Command}`); + execute(message, args) { + let ping = Date.now() - message.createdTimestamp + " ms"; + + const PingCommandEmbed = new Discord.MessageEmbed() + .setDescription(`🏓 **Pong!** \`${Date.now() - message.createdTimestamp}ms\``) + .setColor(supportbot.EmbedColour) - const embed = new Discord.MessageEmbed() - .setDescription(`:ping_pong: **Pong!** \`${bot.ping}ms\` `) - .setColor(supportbot.EmbedColour) - message.channel.send(embed).catch(console.error); - -}; - -exports.help = { - name: supportbot.Ping_Command, -} + message.channel.send({ embed: PingCommandEmbed }); + } +}; \ No newline at end of file diff --git a/commands/poll.js b/commands/poll.js deleted file mode 100644 index 94a1858..0000000 --- a/commands/poll.js +++ /dev/null @@ -1,50 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Poll - -const Discord = require("discord.js"); -const bot = new Discord.Client(); - -const fs = require("fs"); -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Poll_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === `${supportbot.StaffRole}`) - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - const embed = new Discord.MessageEmbed() - .setTitle(`${supportbot.Poll_Title}`) - .setDescription(args.join(" ")) - .setTimestamp() - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL) - - let locateChannel = message.guild.channels.cache.find(LocateChannel => LocateChannel.name === `${supportbot.Poll_Channel}`) - - const errornochannel = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.Poll_Channel}\`\n\nError Code: \`SB-03\``) - .setColor(supportbot.ErrorColour); - if(!locateChannel) return message.channel.send(errornochannel); - - locateChannel.send(embed) - - .then(async function(msg) { - msg.react(supportbot.Reaction_Poll_1).then(() => msg.react(supportbot.Reaction_Poll_2)); - }); - -}; - -exports.help = { - name: supportbot.Poll_Command, -}; diff --git a/commands/remove.js b/commands/remove.js deleted file mode 100644 index e35226f..0000000 --- a/commands/remove.js +++ /dev/null @@ -1,53 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Remove - -const Discord = require("discord.js"); -const bot = new Discord.Client(); - -const fs = require("fs"); -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = async (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Remove_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.StaffRole); - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - const outsideticket = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) - .setColor(supportbot.WarningColour); - if (!message.channel.name.startsWith(`${supportbot.Ticket_Channel_Name}-`)) return message.channel.send({embed: outsideticket}); - - let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); - - const cantfinduser = new Discord.MessageEmbed() - .setTitle("Invalid User!") - .setDescription(`:warning: This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.Remove_Command} \``) - .setColor(supportbot.WarningColour); - if(!rUser) return message.channel.send({embed: cantfinduser}); - - message.channel.updateOverwrite(rUser, { VIEW_CHANNEL: false, CREATE_INVITE: false, SEND_MESSAGES: false, READ_MESSAGES: false }); - - const useradded = new Discord.MessageEmbed() - .setColor(supportbot.EmbedColour) - .setTitle("User Removed") - .setDescription(`👍 ${rUser} has been removed from this ticket`) - .setTimestamp(); - - message.channel.send({embed: useradded}); - -}; - -exports.help = { - name: supportbot.Remove_Command, - } diff --git a/commands/rename.js b/commands/rename.js deleted file mode 100644 index 603ac96..0000000 --- a/commands/rename.js +++ /dev/null @@ -1,53 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Rename - -const Discord = require("discord.js"); -const bot = new Discord.Client(); - -const fs = require("fs"); -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = async (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Rename_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.StaffRole); - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - const outsideticket = new Discord.MessageEmbed() - .setDescription(`:x: Cannot use this command becase you are outside a ticket channel.`) - .setColor(supportbot.colour) - if (!message.channel.name.startsWith(`${supportbot.Ticket_Channel_Name}-`)) return message.channel.send({embed: outsideticket}); - const renameto = args.join(" ") - message.channel.setName(`${supportbot.Ticket_Channel_Name}-${renameto}`) - - // Renamed Ticket Logistic - const logEmbed = new Discord.MessageEmbed() - .setTitle(":ticket: Ticket Renamed") - .setDescription(`<@${message.author.id}> has renamed a ticket to ${supportbot.Ticket_Channel_Name}-${renameto}`) - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter) - - let locateChannel = message.guild.channels.cache.find(LocateChannel => LocateChannel.name === `${supportbot.Ticket_Logs}`) - - const errornochannel = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.Ticket_Logs}\`\n\nError Code: \`SB-03\``) - .setColor(supportbot.ErrorColour); - if(!locateChannel) return message.channel.send(errornochannel); - - locateChannel.send(logEmbed) - -}; - -exports.help = { - name: supportbot.Rename_Command, -} diff --git a/commands/report.js b/commands/report.js deleted file mode 100644 index eb2acd2..0000000 --- a/commands/report.js +++ /dev/null @@ -1,69 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Report - -const Discord = require("discord.js"); -const bot = new Discord.Client(); - -const fs = require("fs"); -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Report_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === `${supportbot.StaffRole}`); - - if(!staffGroup) { - message.reply(rolemissing).catch(err => { - console.error(err); - }); - } else { - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour) - - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - if(!message.member.roles.cache.has(staffGroup.id)) { - message.reply(donothaverole); - } else { - if(!args[0]) { - message.reply(":x: Sorry! Please specify the user to report."); - } else { - if(!args[1]) { - message.reply(":x: Sorry! Specify the reason of your report."); - } else { - let reportDesc = args.slice(1).join(" "); - const embed = new Discord.MessageEmbed() - .setTitle(`${supportbot.Report_Title}`) - .setThumbnail(message.author.avatarURL) - .addField("Report by:", `<@${message.author.id}>`, false) - .addField("Description:", `${reportDesc}`, false) - .addField("Reported User:", `${args[0]}`, false) - .setTimestamp(new Date()) - .setColor(supportbot.EmbedColour) - .setFooter(`${message.author.username}#${message.author.discriminator}`, message.author.displayAvatarURL); - let locateChannel = message.guild.channels.cache.find(LocateChannel => LocateChannel.name === `${supportbot.Report_Channel}`) - if(!locateChannel) { - const errornochannel = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.Report_Channel}\`\n\nError Code: \`SB-03\``) - .setColor(supportbot.ErrorColour); - if(!locateChannel) return message.channel.send(errornochannel); - - } else { - locateChannel.send(embed); - - } - } - } - } - } -}; - -exports.help = { - name: supportbot.Report_Command -} diff --git a/commands/say.js b/commands/say.js deleted file mode 100644 index f0cd41a..0000000 --- a/commands/say.js +++ /dev/null @@ -1,38 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Say - -const Discord = require("discord.js"); -const bot = new Discord.Client(); - -const fs = require("fs"); -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Say_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.StaffRole); - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - const embed = new Discord.MessageEmbed() - .setTitle(`${supportbot.Announcement_Title}`) - .setDescription(args.join(" ")) - .setTimestamp() - .setColor(supportbot.EmbedColour) - .setFooter(`${message.author.username}#${message.author.discriminator}`, message.author.displayAvatarURL) - - message.channel.send(embed); - -}; - -exports.help = { - name: supportbot.Say_Command, -} diff --git a/commands/suggest.js b/commands/suggest.js index 344d8f8..64aadb0 100644 --- a/commands/suggest.js +++ b/commands/suggest.js @@ -1,49 +1,57 @@ - -// SupportBot -// Created by © 2020 Emerald Services -// Command: Say +// SupportBot 6.0, Created by Emerald Services +// Suggest Command const Discord = require("discord.js"); -const bot = new Discord.Client(); - const fs = require("fs"); -const yaml = require('js-yaml'); +const yaml = require('js-yaml'); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); -exports.run = async(bot, message, args) => { +module.exports = { + name: supportbot.SuggestCommand, + + execute(message, args) { + let locateChannel = message.guild.channels.cache.find(SuggestionChannel => SuggestionChannel.name === supportbot.SuggestionChannel); + + const errornochannel = new Discord.MessageEmbed() + .setTitle("SupportBot Error!") + .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.SuggestionChannel}\`\n\nError Code: \`SB-03\``) + .setColor(supportbot.ErrorColour); + + if(!locateChannel) return message.channel.send({ embed: errornochannel }); + + const embed = new Discord.MessageEmbed() + .setDescription(`> **${supportbot.SuggestionStarter}**`) + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: embed }); + + let suggestion = [] + message.channel.awaitMessages(response => response.content.length > 2, { + max: 1, + time: 500000, + errors: ['time'], + }).then((collected) => { + suggestion.push(collected.map(r => r.content)); + + const SuggestionMessage = new Discord.MessageEmbed() + .setColor(supportbot.EmbedColour) + .setFooter(supportbot.EmbedFooter) + + .setTitle(supportbot.SuggestionTitle) + .setDescription(`\`\`\`${suggestion}\`\`\``) + + .addFields( { name: "From", value: `<@${message.author.id}>`, inline: false }, ) + + locateChannel.send({ embed: SuggestionMessage }).then(async function(msg) { + msg.react(supportbot.SuggestReact_1).then(() => msg.react(supportbot.SuggestReact_2)); + }); + + const SuggestionComplete = new Discord.MessageEmbed() + .setColor(supportbot.SuccessColour) + .setDescription(`:white_check_mark: Your suggestion has been successfully created. <#${locateChannel.id}>`) + message.channel.send({ embed: SuggestionComplete }) + + }); - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Suggest_Command}`); - - const SuggestionEmbed = new Discord.MessageEmbed() - .setTitle(`${supportbot.Suggestion_Title}`) - .setDescription(`\`\`\`${args.join(" ")}\`\`\`\nFrom <@${message.author.id}>`) - .setThumbnail(message.author.avatarURL) - .setFooter(`${supportbot.EmbedFooter}`) - .setTimestamp(new Date()) - .setColor(supportbot.EmbedColour) - - let locateChannel = message.guild.channels.cache.find(LocateChannel => LocateChannel.name === `${supportbot.Suggestion_Channel}`) - - const errornochannel = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.Suggestion_Channel}\`\n\nError Code: \`SB-03\``) - .setColor(supportbot.ErrorColour); - if(!locateChannel) return message.channel.send(errornochannel); - - locateChannel.send(SuggestionEmbed) - - .then(async function(msg) { - msg.react(supportbot.suggestyes).then(() => msg.react(supportbot.suggestno)); - }); - - const SuggestionSuccessEmbed = new Discord.MessageEmbed() - .setDescription(`👍 Suggestion has been successfully created\nYou can view your suggestion in <#${locateChannel.id}>`) - .setColor(supportbot.EmbedColour) - message.channel.send(SuggestionSuccessEmbed); - -}; - -exports.help = { - name: supportbot.Suggest_Command, -} + } +}; \ No newline at end of file diff --git a/commands/ticket.js b/commands/ticket.js deleted file mode 100644 index 8e0ebf3..0000000 --- a/commands/ticket.js +++ /dev/null @@ -1,166 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Ticket - -const Discord = require("discord.js"); -const bot = new Discord.Client(); - -const fs = require("fs"); -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); -const TicketNumberID = require('../utility/TicketNumber'); - -exports.run = async (bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Ticket_Command}`); - - // Ticket Number ID Settings - let ticketNumberID = TicketNumberID.pad(message.guild.id); - - // Ticket Subject Settings - const subject = args.join(" ") || `${supportbot.Default_Ticket_Reason}`; - - // Ticket Limitiations - const alreadyopen = new Discord.MessageEmbed() - .setDescription(`:x: Cannot create a ticket because **${supportbot.Ticket_Channel_Name}-${ticketNumberID}** already exists.`) - .setColor(supportbot.EmbedColour) - - // Ticket Creation - if (message.guild.channels.cache.find(TicketChannel => TicketChannel.name === `${supportbot.Ticket_Channel_Name}-` + message.author.username)) return message.channel.send(alreadyopen); - message.guild.channels.create(`${supportbot.Ticket_Channel_Name}-${ticketNumberID}`, { - type: 'text', - }).then(TicketChannel => { - - // Roles - let staff = message.guild.roles.cache.find(supportRole => supportRole.name === `${supportbot.StaffRole}`) - let everyone = message.guild.roles.cache.find(everyoneRole => everyoneRole.name === supportbot.everyone) - let department = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.Department_Role_1}`) - let department2 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.Department_Role_2}`) - let department3 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.Department_Role_3}`) - - // Permissions - TicketChannel.updateOverwrite(everyone, { VIEW_CHANNEL: false }); - TicketChannel.updateOverwrite(message.author, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: false, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(staff, { VIEW_CHANNEL: true, CREATE_INVITE: false, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(department, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(department2, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(department3, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - - // Category - let category = message.guild.channels.cache.find(c => c.name === supportbot.category); - if (category) { - TicketChannel.setParent(category.id); - } else { - if (message.guild.channels.cache.get(supportbot.category)) { - TicketChannel.setParent(message.guild.channels.cache.get(supportbot.category).id); - } - } - - const ticketopened = new Discord.MessageEmbed() - .setTitle(":white_check_mark: Support Ticket Created") - .setDescription(`<@${message.author.id}> your support ticket created successfully`) - .addField("Your Ticket:", `<#${TicketChannel.id}>`) - .setColor(supportbot.SuccessColour) - message.channel.send({embed: ticketopened}); - // Ticket Message - ( Able to edit this message via the settings.json file ) - const ticketMessage = `Hi! <@${message.author.id}>\n${supportbot.Ticket_Message}`; - - const Department_1 = supportbot.Ticket_Department_1; - const Department_2 = supportbot.Ticket_Department_2; - const Department_3 = supportbot.Ticket_Department_3; - - const Emoji_1 = supportbot.Ticket_Department_Emoji_1; - const Emoji_2 = supportbot.Ticket_Department_Emoji_2; - const Emoji_3 = supportbot.Ticket_Department_Emoji_3; - - const TicketMessage = new Discord.MessageEmbed() - .setDescription(ticketMessage, true) - .addField("Available Departments", `${Emoji_1} ${Department_1}\n${Emoji_2} ${Department_2}\n${Emoji_3} ${Department_3}`) - .setColor(supportbot.Ticket_Colour) - .setFooter(supportbot.EmbedFooter) - - if (subject != 'No Subject.') { - TicketMessage.addField("Reason", subject); - } - - - TicketChannel.send({embed: TicketMessage}).then(function(msg) { - - msg.react(Emoji_1).then(() => msg.react(Emoji_2)).then(() => msg.react(Emoji_3)); - - const filter = (reaction, user) => { - return [Emoji_1, Emoji_2, Emoji_3].includes(reaction.emoji.name) && user.id !== msg.author.id; - }; - - msg.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] }) - .then(collected => { - const reaction = collected.first(); - - if (reaction.emoji.name === `${Emoji_1}`) { - TicketChannel.updateOverwrite(message.author, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(staff, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(department, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - - const dept1 = new Discord.MessageEmbed() - .setDescription(`You have requested to contact ${department}. Please wait patiently for someone to reach out to you.`) - .setColor(supportbot.SuccessColour) - TicketChannel.send(dept1) - } - - if (reaction.emoji.name === `${Emoji_2}`) { - TicketChannel.updateOverwrite(message.author, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(staff, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(department2, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - - const dept2 = new Discord.MessageEmbed() - .setDescription(`You have requested to contact ${department2}. Please wait patiently for someone to reach out to you.`) - .setColor(supportbot.SuccessColour) - TicketChannel.send(dept2) - } - - if (reaction.emoji.name === `${Emoji_3}`) { - TicketChannel.updateOverwrite(message.author, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(staff, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - TicketChannel.updateOverwrite(department3, { VIEW_CHANNEL: true, CREATE_INVITE: false, SEND_MESSAGES: true, READ_MESSAGES: true }); - - const dept3 = new Discord.MessageEmbed() - .setDescription(`You have requested to contact ${department3}. Please wait patiently for someone to reach out to you.`) - .setColor(supportbot.SuccessColour) - TicketChannel.send(dept3) - } - - }); - - }); - - // Ticket Logging - const logEmbed = new Discord.MessageEmbed() - .setTitle(":ticket: Ticket Log") - .addField("Ticket ID", ticketNumberID, true) - .addField("User", `<@${message.author.id}>`, true) - .addField("Channel", `ticket#${ticketNumberID}`, true) - .setColor(supportbot.EmbedColour) - .setFooter(supportbot.EmbedFooter) - - if (subject != 'No Subject.') { - logEmbed.addField('Subject', subject, true); - } - - let locateChannel = message.guild.channels.cache.find(LocateChannel => LocateChannel.name === `${supportbot.Ticket_Logs}`) - - const errornochannel = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Channel not Found, This command cannot be executed proberbly as their is no channel within this server.\nThis is configurable via **supportbot-config.yml**\n\nChannel Required: \`${supportbot.Ticket_Logs}\`\n\nError Code: \`SB-03\``) - .setColor(supportbot.ErrorColour); - if(!locateChannel) return message.channel.send(errornochannel); - - locateChannel.send(logEmbed) - - }).catch(err=>{console.error(err)}); - -}; - -exports.help = { - name: supportbot.Ticket_Command, -}; diff --git a/commands/unlock.js b/commands/unlock.js deleted file mode 100644 index e915019..0000000 --- a/commands/unlock.js +++ /dev/null @@ -1,38 +0,0 @@ -// SupportBot -// Created by © 2020 Emerald Services -// Command: Say - -const Discord = require("discord.js"); -const bot = new Discord.Client(); - -const fs = require("fs"); -const yaml = require('js-yaml'); - -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -exports.run = async(bot, message, args) => { - - console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.UnLockchat_Command}`); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === `${supportbot.StaffRole}`) - let lockedRole = message.guild.roles.cache.find(lc => lc.name === `${supportbot.locked_role}`) - - const rolerequired = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Incorrect Permissions, You cannot execute this command as you do not have the required role.\n\nRole Required: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-02\``) - .setColor(supportbot.ErrorColour); - if (!message.member.roles.cache.has(staffGroup.id)) return message.reply({embed: rolerequired}); - - message.channel.updateOverwrite(lockedRole, { READ_MESSAGES: true, SEND_MESSAGES: true }); - message.channel.updateOverwrite(staffGroup, { READ_MESSAGES: true, SEND_MESSAGES: true }); - - const lockmsg = new Discord.MessageEmbed() - .setDescription(":white_check_mark: **Chat Un-Locked**") - .setColor(supportbot.EmbedColour); - message.channel.send(lockmsg); - -}; - -exports.help = { - name: supportbot.UnLockchat_Command, -} diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index 0847467..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ - cd /home/container - -if [ "${GIT_CLONE}" == "true" ] || [ "${GIT_CLONE}" == "1" ]; then - if [ "$(ls -A /home/container)" ]; then - echo "Pulling Updates" - git pull - else - echo -e "/home/container is empty.\nCloning files into the directory." - git clone https://github.com/1tzemerald/SupportBot.git - fi -fi - -sed -i '/s/BOT_TOKEN_HERE/${BOT_TOKEN}/g' settings.json -MODIFIED_STARTUP=`eval echo $(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')` -${MODIFIED_STARTUP} diff --git a/events/message.js b/events/message.js new file mode 100644 index 0000000..f3a92fb --- /dev/null +++ b/events/message.js @@ -0,0 +1,24 @@ +// SupportBot 6.0, Created by Emerald Services +// Message Event + +const Discord = require("discord.js"); +const fs = require("fs"); + +const yaml = require('js-yaml'); +const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); + +module.exports = async (bot, message) => { + if(message.author.bot) return; + if(message.channel.type === "dm") return; + if (message.content.indexOf(supportbot.Prefix) !== 0) return; + + let messageArray = message.content.split(" "); + const args = message.content.slice(supportbot.Prefix.length).trim().split(/ +/g); + const command = args.shift().toLowerCase(); + + const cmd = bot.commands.get(command); + if(!cmd) return; + cmd.execute(message, args); + message.delete(); + +}; \ No newline at end of file diff --git a/events/ready.js b/events/ready.js new file mode 100644 index 0000000..99b8b66 --- /dev/null +++ b/events/ready.js @@ -0,0 +1,19 @@ +// SupportBot 6.0, Created by Emerald Services +// Ready Event + +const Discord = require("discord.js"); +const fs = require("fs"); + +const yaml = require('js-yaml'); +const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); + + +module.exports = async (bot) => { + bot.user.setActivity(supportbot.BotActivity, { + type: supportbot.ActvityType + }); + + console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`) + console.log(`\u001b[37m`, `${supportbot.Bot_Name} has successfully connected to discord`) + console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`) +}; \ No newline at end of file diff --git a/index.js b/index.js index 57f7469..674321e 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,13 @@ -// ____ _ ____ _ -// / ___| _ _ _ __ _ __ ___ _ __| |_| __ ) ___ | |_ -// \___ \| | | | '_ \| '_ \ / _ \| '__| __| _ \ / _ \| __| -// ___) | |_| | |_) | |_) | (_) | | | |_| |_) | (_) | |_ -// |____/ \__,_| .__/| .__/ \___/|_| \__|____/ \___/ \__| -// |_| |_| -// © 2020 Created by Emerald Services -// Licnese: MIT -// SupportBot v5.2 +// _________ __ __________ __ +// / _____/__ ________ ______ ____________/ |\______ \ _____/ |_ +// \_____ \| | \____ \\____ \ / _ \_ __ \ __\ | _// _ \ __\ +// / \ | / |_> > |_> > <_> ) | \/| | | | ( <_> ) | +// /_______ /____/| __/| __/ \____/|__| |__| |______ /\____/|__| +// \/ |__| |__| \/ +// +// SupportBot version 6.0 +// Created by Emerald Services +// Installed with MIT License const Discord = require("discord.js"); const fs = require("fs"); @@ -17,141 +18,73 @@ bot.commands = new Discord.Collection(); const yaml = require('js-yaml'); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); -fs.readdir("./commands/", (err, files) => { - if(err) console.log(err); - - let jsfile = files.filter(f => f.split(".").pop() === "js") - if(jsfile.length <= 0) return console.log(`${supportbot.Bot_Name} No commands found. Try to Re-download the resource`); - - jsfile.forEach((f, i) =>{ - let props = require(`./commands/${f}`); - console.log(`[${supportbot.Bot_Name}] > Command Loaded > ${f}`); - bot.commands.set(props.help.name, props); - }); - - }); +const { promisify } = require("util"); +const readdir = promisify(require("fs").readdir); -bot.addons = new Discord.Collection(); +String.prototype.toProperCase = function () { + return this.replace( + /([^\W_]+[^\s-]*) */g, + (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() + ); +}; -fs.readdir("./sb-addons/", (err, files) => { - if(err) console.log(err); - - let jsfile = files.filter(f => f.split(".").pop() === "js") - if(jsfile.length <= 0) return console.log(`${supportbot.Bot_Name} No addons detected nor default! Either download addons from https://emeraldservices.xyz/`); - - jsfile.forEach((f, i) =>{ - let props = require(`./sb-addons/${f}`); - console.log(`[${supportbot.Bot_Name}] > Addons Loaded > ${f}`); - bot.addons.set(props.help.name, props); - }); - - }); - -bot.on("ready", async () => { - bot.user.setActivity(supportbot.BotActivity, {type: supportbot.ActvityType}); - console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`) - console.log(`\u001b[37m`, `${supportbot.Bot_Name} has successfully connected to discord`) - console.log(`\u001b[37m`, `You can download additional features from our marketplace https://emeraldservices.xyz/`) - console.log(`\u001b[37m`, `Invite your bot with https://discordapp.com/api/oauth2/authorize?client_id=${bot.user.id}&permissions=8&scope=bot`) - console.log(`\u001b[37m`, `© SupportBot created by Emerald Services`) - console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`) - -}); - -bot.on("message", async message => { - if(message.author.bot) return; - if(message.channel.type === "dm") return; - if (message.content.indexOf(supportbot.Prefix) !== 0) return; - - let messageArray = message.content.split(" "); - const args = message.content.slice(supportbot.Prefix.length).trim().split(/ +/g); - const command = args.shift().toLowerCase(); - - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === `${supportbot.StaffRole}`) - let autoGroup = message.guild.roles.cache.find(autoRole => autoRole.name === `${supportbot.AutoRole}`) - let deptGroup1 = message.guild.roles.cache.find(deptRole1 => deptRole1.name === `${supportbot.Department_Role_1}`) - let deptGroup2 = message.guild.roles.cache.find(deptRole2 => deptRole2.name === `${supportbot.Department_Role_2}`) - let deptGroup3 = message.guild.roles.cache.find(deptRole3 => deptRole3.name === `${supportbot.Department_Role_3}`) - - const rolemissing = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Staff role missing, You cannot execute any commands as the following role does not exist with this server.\nThis role is configurable via **supportbot-config.yml**\n\nPlease create the role: \`${supportbot.StaffRole}\`\n\nError Code: \`SB-01\``) - .setColor(supportbot.ErrorColour) - if (!staffGroup) return message.reply(rolemissing).catch(err=>{console.error(err)}) - - const rolemissing1 = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Auto Role missing, You cannot execute any commands as the following role does not exist with this server.\nThis role is configurable via **supportbot-config.yml**\n\nPlease create the role: \`${supportbot.AutoRole}\`\n\nError Code: \`SB-01\``) - .setColor(supportbot.ErrorColour) - if (!autoGroup) return message.reply(rolemissing1).catch(err=>{console.error(err)}) - - const rolemissing2 = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Department Role missing, You cannot execute any commands as the following role does not exist with this server.\nThis role is configurable via **supportbot-config.yml**\n\nPlease create the role: \`${supportbot.Department_Role_1}\`\n\nError Code: \`SB-01\``) - .setColor(supportbot.ErrorColour) - if (!deptGroup1) return message.reply(rolemissing2).catch(err=>{console.error(err)}) - - const rolemissing3 = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Department Role missing, You cannot execute any commands as the following role does not exist with this server.\nThis role is configurable via **supportbot-config.yml**\n\nPlease create the role: \`${supportbot.Department_Role_2}\`\n\nError Code: \`SB-01\``) - .setColor(supportbot.ErrorColour) - if (!deptGroup2) return message.reply(rolemissing3).catch(err=>{console.error(err)}) - - const rolemissing4 = new Discord.MessageEmbed() - .setTitle("SupportBot Error!") - .setDescription(`:x: **Error!** Department Role missing, You cannot execute any commands as the following role does not exist with this server.\nThis role is configurable via **supportbot-config.yml**\n\nPlease create the role: \`${supportbot.Department_Role_3}\`\n\nError Code: \`SB-01\` `) - .setColor(supportbot.ErrorColour) - if (!deptGroup3) return message.reply(rolemissing4).catch(err=>{console.error(err)}) - - const cmd = bot.commands.get(command); - if(!cmd) return; - cmd.run(bot, message, args); - message.delete(); -}); - -bot.on("message", async message => { - if(message.author.bot) return; - if(message.channel.type === "dm") return; - if (message.content.indexOf(supportbot.Prefix) !== 0) return; - - let messageArray = message.content.split(" "); - const args = message.content.slice(supportbot.Prefix.length).trim().split(/ +/g); - const addon = args.shift().toLowerCase(); - - const cmd = bot.addons.get(addon); - if(!cmd) return; - cmd.run(bot, message, args); - message.delete(); -}); - -// [SupportBot] Welcome Message && Auto Join Role - -bot.on("guildMemberAdd", (member) => { - let channel = member.guild.channels.cache.find(channel => channel.name === `${supportbot.WelcomeChannel}`) - let autorole = member.guild.roles.cache.find(autorole => autorole.name === `${supportbot.AutoRole}`) - - const WelcomeMsg = new Discord.MessageEmbed() - .setColor(supportbot.EmbedColour) - .setThumbnail(member.user.avatarURL) - .setDescription(`:wave: ${member.user.username}\n${supportbot.WelcomeMessage}`) - - channel.send(WelcomeMsg); - member.roles.add(autorole).catch(console.error); +const init = async () => { + const evtFiles = await readdir("./events/"); + evtFiles.forEach((file, i) => { + const eventName = file.split(".")[0]; + const event = require(`./events/${file}`); + + console.info(`\u001b[37m`, `[${supportbot.Bot_Name}]:`, `\u001b[31m`, `#${i + 1} Event Loaded: ${eventName.toProperCase()} `); + + bot.on(eventName, event.bind(null, bot)); + delete require.cache[require.resolve(`./events/${file}`)]; + }); + + console.info(`\u001b[37m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `Successfully loaded ${evtFiles.length} events.`); + console.info(`\u001b[37m`, "-----------------------------------------------------------------------------"); +}; + +init(); + +fs.readdir("./commands/", (err, files) => { + if (err) console.info(err, "error"); + + let jsfiles = files.filter((f) => f.split(".").pop() === "js"); + + if (jsfiles.length <= 0) { + console.log(`[${supportbot.Bot_Name}]: No commands found. Try to Re-download the resource`); + return; + } + + jsfiles.forEach((f, i) => { + let props = require(`./commands/${f}`); + console.info(`\u001b[37m`, `[${supportbot.Bot_Name}]:`, `\u001b[31m`, `#${i + 1} Command Loaded: ${props.name.toProperCase()}`); + bot.commands.set(props.name, props); + }); + + console.info(`\u001b[37m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `Loaded ${jsfiles.length} commands!`); + console.info(`\u001b[37m`, "-----------------------------------------------------------------------------"); }); -// [SupportBot] Leave Message +fs.readdir("./addons/", (err, files) => { + if (err) console.info(err, "error"); + + let jsfiles = files.filter((f) => f.split(".").pop() === "js"); -bot.on("guildMemberRemove", (member) => { - let channel = member.guild.channels.cache.find(channel => channel.name === `${supportbot.LeaveChannel}`) - - const LeaveMsg = new Discord.MessageEmbed() - .setColor(supportbot.EmbedColour) - .setThumbnail(member.user.avatarURL) - .setDescription(`:wave: ${member.user.username}\n${supportbot.LeaveMessage}`) - - channel.send(LeaveMsg); + if (jsfiles.length <= 0) { + console.log(`[${supportbot.Bot_Name}]: No addons found. You can download addons from https://emeraldservices.xyz`); + return; + } + + jsfiles.forEach((f, i) => { + let props = require(`./commands/${f}`); + console.info(`\u001b[37m`, `[${supportbot.Bot_Name}]:`, `\u001b[31m`, `#${i + 1} Command Loaded: ${props.name.toProperCase()}`); + bot.commands.set(props.name, props); + }); + console.info(`\u001b[37m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `Loaded ${jsfiles.length} commands!`); + console.info(`\u001b[37m`, "-----------------------------------------------------------------------------"); }); bot.login(supportbot.Token); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b5daa9c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,134 @@ +{ + "name": "supportbot", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@discordjs/collection": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.5.tgz", + "integrity": "sha512-CU1q0UXQUpFNzNB7gufgoisDHP7n+T3tkqTsp3MNUkVJ5+hS3BCvME8uCXAUFlz+6T2FbTCu75A+yQ7HMKqRKw==" + }, + "@discordjs/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "requires": { + "event-target-shim": "^5.0.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "discord.js": { + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.2.0.tgz", + "integrity": "sha512-Ueb/0SOsxXyqwvwFYFe0msMrGqH1OMqpp2Dpbplnlr4MzcRrFWwsBM9gKNZXPVBHWUKiQkwU8AihXBXIvTTSvg==", + "requires": { + "@discordjs/collection": "^0.1.5", + "@discordjs/form-data": "^3.0.1", + "abort-controller": "^3.0.0", + "node-fetch": "^2.6.0", + "prism-media": "^1.2.0", + "setimmediate": "^1.0.5", + "tweetnacl": "^1.0.3", + "ws": "^7.2.1" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "requires": { + "mime-db": "1.44.0" + } + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "prism-media": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz", + "integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==" + }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + }, + "ws": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", + "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==" + } + } +} diff --git a/package.json b/package.json index b92fa1d..17deb5a 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "supportbot", - "version": "5.1.0", - "description": "a discord dbot that can you help with your servers support", + "version": "1.0.0", + "description": "A self hosted discord support bot. SUPPORTBOT v6 GO CRAZYYYY", "main": "index.js", "scripts": { - "test": "-help" + "test": "echo \"Error: no test specified\" && exit 1" }, - "author": "Emerald SRV", - "license": "MIT", + "author": "", + "license": "ISC", "dependencies": { - "discord.js": "^12.1.1", + "discord.js": "^12.2.0", "js-yaml": "^3.13.1" } } diff --git a/sb-addons/default-addon.js b/sb-addons/default-addon.js deleted file mode 100644 index 91828fc..0000000 --- a/sb-addons/default-addon.js +++ /dev/null @@ -1,19 +0,0 @@ -// SupportBot Addons -// Default Addon - -const Discord = require("discord.js"); -const bot = new Discord.Client() -const someaddon = new Discord.Client() - -someaddon.settings = require("./settings/someaddon.json"); - -exports.run = async(bot, message, args) => { - message.delete(); - - message.channel.send(":white_check_mark: **SupportBot Addon**\nYou can download addons from our marketplace. https://emeraldservices.xyz/") - -} - -exports.help = { - name: someaddon.settings.Addon_Example_Command, -} diff --git a/sb-addons/settings/someaddon.json b/sb-addons/settings/someaddon.json deleted file mode 100644 index 60ccd58..0000000 --- a/sb-addons/settings/someaddon.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - - "Addon_Example_Command": "addonexample" - -} diff --git a/storage/SupportTickets.json b/storage/SupportTickets.json new file mode 100644 index 0000000..3eeb8dc --- /dev/null +++ b/storage/SupportTickets.json @@ -0,0 +1,4 @@ +{ + "ticket": "ticket-0046", + "id":419821884431925260 +} \ No newline at end of file diff --git a/storage/TicketID.json b/storage/TicketID.json new file mode 100644 index 0000000..338ee2f --- /dev/null +++ b/storage/TicketID.json @@ -0,0 +1,5 @@ +{ + "716992597377286145": { + "id": 47 + } +} \ No newline at end of file diff --git a/storage/tickets.json b/storage/tickets.json deleted file mode 100644 index 9e26dfe..0000000 --- a/storage/tickets.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml new file mode 100644 index 0000000..a2c0574 --- /dev/null +++ b/supportbot-config.yml @@ -0,0 +1,155 @@ +# _________ __ __________ __ +# / _____/__ ________ ______ ____________/ |\______ \ _____/ |_ +# \_____ \| | \____ \\____ \ / _ \_ __ \ __\ | _// _ \ __\ +# / \ | / |_> > |_> > <_> ) | \/| | | | ( <_> ) | +# /_______ /____/| __/| __/ \____/|__| |__| |______ /\____/|__| +# \/ |__| |__| \/ +# +# SupportBot version 6.0 +# Created by Emerald Services +# Installed with MIT License + +# General Bot Configuration + +Token: "TOKEN" +Prefix: "!!" +Bot_Name: "SupportBot DEV" + +BotActivity: "SB-6.0 dev-0.1" +ActivityType: "PLAYING" + +# Embed Configuration + +EmbedColour: "#04b545" +EmbedFooter: "SupportBot | The #1 Supportive Discord Bot" + +ErrorColour: "#d12519" +SuccessColour: "#04b545" +WarningColour: "#fca117" + +# Role Configuration + +AutoRole: "Member" + +Staff: "Support" +Admin: "Admin" + +# Ticket Configuration + +TicketChannel: "ticket" +TicketCategory: "Tickets" +TicketLog: "ticket-logs" +TranscriptLog: "transcripts" +TicketSubject: "description" + +Ticket_Thumbnail: "https://images.emojiterra.com/google/android-pie/512px/1f39f.png" +Ticket_Title: "Server Support | %ticketusername%" +TicketMessage: "Hello <@%ticketauthor%>, Thank you for creating a support ticket\nPlease wait patiently whilst a member of our team reaches out to you." +NoTicketSubject: "No Reason Provided!" +TicketCreatedAlert: ":ticket: Your support ticket has been created: <#%ticketid%>" + +TicketPanel: true +ReactionForTicket: 🎫 + +# Ticket Department Configuration + +TicketDepartments: true +# This option enable or disable the ticket departments. If set false Ticket Departments will not work + +AllowStaff: true +# AllowStaff is an option to whether or not you want the users with the "Staff" role to be able to view inside tickets. If set false "Staff" will not view tickets. + +DepartmentTiming: "1000" + +DepartmentEmoji_1: "🙋" +DepartmentEmoji_2: "💸" +DepartmentEmoji_3: "📗" +# Ticket emojis, the emojis are what users will need to react with inorder to proceed furthur if departments are enabled. + +DepartmentTitle_1: "Support" +DepartmentTitle_2: "Billing" +DepartmentTitle_3: "Other" +# Ticket department title, This is the title for a ticket department to help users know what is available. + +DepartmentRole_1: "Support" +DepartmentRole_2: "Admin" +DepartmentRole_3: "Support" +# Ticket roles are the roles that will be able to gain access to tickets depending on what department has been choosen. + +# System Message Configuration + +SystemMessages: "true" + +SystemMessage_Channel: "system-messages" +SystemMessages_Embed: "true" + +WelcomeMessage: "Hello %membertag%, Welcome to %guildname%!" +LeaveMessage: "Goodbye %membertag%, Thank you for visting %guildname%!" + +# LINKS Configuration + +LinksTitle: "Quick Links" + +LINKS: + "Website": "https://www.example.com" + "Store": "https://store.example.com" + "Discord": "https://discord.gg/example" + +# Suggestions Configuration + +SuggestionChannel: "suggestions" +SuggestionTitle: "Suggestion" +SuggestionStarter: "What would you like to suggest?" +SuggestReact_1: 👍 +SuggestReact_2: 👎 + +# Poll Configuration + +PollChannel: "polls" +PollTitle: "Suggestion" +PollStarter: "What would you like to create a poll about?" +PollReact_1: 👍 +PollReact_2: 👎 + + +# Announcement Configuration + +AnnouncementChannel: "announcements" +AnnouncementTitle: "Servername Announcement" +AnnouncementIcon: "https://i.imgur.com/HbkZyB7.png" + +AnnouncementStarter: "What would you like to announce?" + +MentionedRole: "@everyone" + +# General Command Configuration + +HelpCommand: "help" +LinksCommand: "links" +PingCommand: "ping" +SuggestCommand: "suggest" + +# Staff Command Configuration + +SayCommand: "say" +ChatLockCommand: "lock" +ChatUnlockCommand: "unlock" + +# Management Command Configuration + +AnnounceCommand: "announce" + +# Support Command Configuration + +NewTicket: "ticket" +CloseTicket: "close" +AddUser: "add" +RemoveUser: "remove" +RenameTicket: "rename" + + + + + + + diff --git a/utility/TicketNumber.js b/utils/TicketNumber.js similarity index 76% rename from utility/TicketNumber.js rename to utils/TicketNumber.js index e39033d..b0ba93d 100644 --- a/utility/TicketNumber.js +++ b/utils/TicketNumber.js @@ -1,4 +1,4 @@ -// SupportBot Utility +// SupportBot Utils // Ticket Numbers const discord = require("discord.js") @@ -21,14 +21,14 @@ class TicketNumberID { static get(guildId) { - let ticketnumberID = JSON.parse(fs.readFileSync("./storage/tickets.json", "utf8")); + let ticketnumberID = JSON.parse(fs.readFileSync("./storage/TicketID.json", "utf8")); if (!ticketnumberID[guildId]) { ticketnumberID[guildId] = { id: 0 } - fs.writeFileSync("./storage/tickets.json", JSON.stringify(ticketnumberID, null, 4), err => { + fs.writeFileSync("./storage/TicketID.json", JSON.stringify(ticketnumberID, null, 4), err => { if (err) console.log(err); }); @@ -41,13 +41,13 @@ class TicketNumberID { } static set(guildId, value) { - let ticketnumberID = JSON.parse(fs.readFileSync("./storage/tickets.json", "utf8")); + let ticketnumberID = JSON.parse(fs.readFileSync("./storage/TicketID.json", "utf8")); ticketnumberID[guildId] = { id: value } - fs.writeFileSync("./storage/tickets.json", JSON.stringify(ticketnumberID, null, 4), err => { + fs.writeFileSync("./storage/TicketID.json", JSON.stringify(ticketnumberID, null, 4), err => { if (err) console.log(err); }); @@ -55,13 +55,13 @@ class TicketNumberID { } static reset(guildId) { - let ticketnumberID = JSON.parse(fs.readFileSync("./storage/tickets.json", "utf8")); + let ticketnumberID = JSON.parse(fs.readFileSync("./storage/TicketID.json", "utf8")); ticketnumberID[guildId] = { id: 0 } - fs.writeFileSync("./storage/tickets.json", JSON.stringify(ticketnumberID, null, 4), err => { + fs.writeFileSync("./storage/TicketID.json", JSON.stringify(ticketnumberID, null, 4), err => { if (err) console.log(err); }); @@ -69,4 +69,4 @@ class TicketNumberID { } } -module.exports = TicketNumberID; +module.exports = TicketNumberID; \ No newline at end of file