From ca7294a0e36e1526f450956cb06d8ac1afa63be1 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Mon, 15 Jun 2020 23:47:10 +0100 Subject: [PATCH 01/33] Delete supportbot-config.yml --- supportbot-config.yml | 120 ------------------------------------------ 1 file changed, 120 deletions(-) delete mode 100644 supportbot-config.yml diff --git a/supportbot-config.yml b/supportbot-config.yml deleted file mode 100644 index c87eaaa..0000000 --- a/supportbot-config.yml +++ /dev/null @@ -1,120 +0,0 @@ -# _________ __ __________ __ -# / _____/__ ________ ______ ____________/ |\______ \ _____/ |_ -# \_____ \| | \____ \\____ \ / _ \_ __ \ __\ | _// _ \ __\ -# / \ | / |_> > |_> > <_> ) | \/| | | | ( <_> ) | -# /_______ /____/| __/| __/ \____/|__| |__| |______ /\____/|__| -# \/ |__| |__| \/ -# -# SupportBot v5.2 -# Created by © 2020 Emerald Services -# License: MIT - -#Bot Indentification -Token: "BOT_TOKEN_HERE" -Prefix: "!" -Bot_Name: "SupportBot" - -BotActivity: "SupportBot v5.2" -ActivityType: "PLAYING" - -EmbedColour: "#4bbf5c" -EmbedFooter: "SupportBot | The #1 Supportive Discord Bot" - -# Colour Settings -ErrorColour: "#ff3030" -SuccessColour: "#4bbf5c" -WarningColour: "#fca117" - -# Role Settings -AutoRole: "Member" -StaffRole: "Support" - -locked_role: "@everyone" -everyone: "@everyone" - -Department_Role_1: "Support" -Department_Role_2: "Sales" -Department_Role_3: "Support" - -# Ticket Department Settings -Ticket_Department_1: "Support" -Ticket_Department_2: "Sales" -Ticket_Department_3: "Other" - -Ticket_Department_Emoji_1: "🟢" -Ticket_Department_Emoji_2: "🔵" -Ticket_Department_Emoji_3: "🔴" - -# Ticket Settings -category: "Tickets" -Ticket_Colour: "#4bbf5c" -Ticket_Channel_Name: "ticket" -Ticket_Logs: "ticket-logs" - -Transcript_Log: "ticket-data" -Transcript_Title: "Support Transcript" - -Ticket_Closing: "⚠ Your ticket is now closing!" -Ticket_Closure: "Looks like you have come to the end of your support ticket\nPlease confirm that you want to close your ticket." -Closure_Confirm_Word: "confirm" - -Ticket_Message: "Your support ticket has been opened successfully\nPlease allow us some time to reach out to you." -Default_Ticket_Reason: "No Subject" - -# Welcome & Leave -WelcomeChannel: "welcome" -WelcomeMessage: "Welcome to the server!" - -LeaveChannel: "welcome" -LeaveMessage: "Thank you for visiting us!" - -# Announcement Settings -Announcement_Title: "SupportBot Announcement" -Announcement_Channel: "announcements" -Announcement_Tag_Role: "@everyone" - -# Poll Settings -Poll_Channel: "polls" -Poll_Title: "📊 Polls" - -Reaction_Poll_1: "✅" -Reaction_Poll_2: "❎" - -# Suggestion Settings -Suggestion_Title: "SupportBot Suggestions" -Suggestion_Channel: "suggestions" - -suggestyes: "✅" -suggestno: "❎" - -# Report Settings -Report_Channel: "reports" -Report_Title: "SupportBot Report" - -# Link Settings -LINKS_TITLE: "SupportBot Links" - -LINKS: - "Discord": "https://discord.gg/" - "Twitter": "https://twitter.com/" - "Website": "https://example.com/" - "AddMore": "AddMoreIfYouWant" - -# Bot Command Settings -Add_Command: "add" -Remove_Command: "remove" -Ticket_Command: "ticket" -Close_Command: "close" -Forceclose_Command: "forceclose" -Rename_Command: "rename" -Lockchat_Command: "lock" -UnLockchat_Command: "unlock" -Announcement_Command: "announce" -Say_Command: "say" -Suggest_Command: "suggest" -Ping_Command: "ping" -Help_Command: "help" -Link_Command: "links" -Poll_Command: "poll" -Report_Command: "report" -Setup_Command: "setup" From eaa9da6d2eea34058f55bf349c8a2b7b29ad8c97 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Mon, 15 Jun 2020 23:58:37 +0100 Subject: [PATCH 02/33] 6.0-Dev Edition --- .gitattributes | 2 - .gitignore | 76 ---------- LICENSE | 2 +- README.md | 29 +++- _config.yml | 1 - commands/add.js | 52 ------- commands/announce.js | 104 +++++++------- commands/close.js | 118 ++-------------- commands/forceclose.js | 70 ---------- commands/help.js | 81 ++++++----- commands/links.js | 46 +++---- commands/lockchat.js | 38 ----- commands/newticket.js | 213 +++++++++++++++++++++++++++++ commands/ping.js | 32 ++--- commands/poll.js | 50 ------- commands/remove.js | 53 ------- commands/rename.js | 53 ------- commands/report.js | 69 ---------- commands/say.js | 38 ----- commands/suggest.js | 92 +++++++------ commands/ticket.js | 166 ---------------------- commands/unlock.js | 38 ----- entrypoint.sh | 15 -- events/message.js | 24 ++++ events/ready.js | 19 +++ index.js | 207 ++++++++++------------------ package-lock.json | 134 ++++++++++++++++++ package.json | 12 +- sb-addons/default-addon.js | 19 --- sb-addons/settings/someaddon.json | 5 - storage/SupportTickets.json | 4 + storage/TicketID.json | 5 + storage/tickets.json | 1 - supportbot-config.yml | 155 +++++++++++++++++++++ {utility => utils}/TicketNumber.js | 16 +-- 35 files changed, 854 insertions(+), 1185 deletions(-) delete mode 100644 .gitattributes delete mode 100644 .gitignore delete mode 100644 _config.yml delete mode 100644 commands/add.js delete mode 100644 commands/forceclose.js delete mode 100644 commands/lockchat.js create mode 100644 commands/newticket.js delete mode 100644 commands/poll.js delete mode 100644 commands/remove.js delete mode 100644 commands/rename.js delete mode 100644 commands/report.js delete mode 100644 commands/say.js delete mode 100644 commands/ticket.js delete mode 100644 commands/unlock.js delete mode 100644 entrypoint.sh create mode 100644 events/message.js create mode 100644 events/ready.js create mode 100644 package-lock.json delete mode 100644 sb-addons/default-addon.js delete mode 100644 sb-addons/settings/someaddon.json create mode 100644 storage/SupportTickets.json create mode 100644 storage/TicketID.json delete mode 100644 storage/tickets.json create mode 100644 supportbot-config.yml rename {utility => utils}/TicketNumber.js (76%) 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 From 698b82c7d34ab0ef9411e449a5b62dd983b009a5 Mon Sep 17 00:00:00 2001 From: Two Date: Mon, 15 Jun 2020 21:29:31 -0400 Subject: [PATCH 03/33] Update newticket.js --- commands/newticket.js | 132 ++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 62 deletions(-) diff --git a/commands/newticket.js b/commands/newticket.js index cfd5fb0..2229e53 100644 --- a/commands/newticket.js +++ b/commands/newticket.js @@ -7,6 +7,8 @@ const yaml = require('js-yaml'); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); const TicketNumberID = require('../utils/TicketNumber.js'); +const reacted = []; + module.exports = { name: supportbot.NewTicket, @@ -105,72 +107,78 @@ module.exports = { const Emoji_2 = supportbot.DepartmentEmoji_2; const Emoji_3 = supportbot.DepartmentEmoji_3; + reacted[ticketNumberID] = false; + if (supportbot.TicketDepartments === true) { - msg.react(Emoji_1).then(() => msg.react(Emoji_2)).then(() => msg.react(Emoji_3)) - - const filter = (reaction, user) => { + await msg.react(Emoji_1); + await msg.react(Emoji_2); + await msg.react(Emoji_3); + let filter = (reaction, user) => { + if (user.bot) return; + if (typeof reacted[ticketNumberID] !== "boolean") return; + delete reacted[ticketNumberID]; + 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 Department3 = 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 }); + } return [Emoji_1, Emoji_2, Emoji_3].includes(reaction.emoji.name) && user.id !== message.author.id; } - + msg.awaitReactions(filter, { + max: 4, + time: 60000, + errors: ['time'] + }).then(async collected => { + }); + 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); - + if (typeof reacted[ticketNumberID] == "boolean") { + delete reacted[ticketNumberID]; + //delete channel because didn't react in a minute + } + }, 60000); + } }); From 575d25f5adbe5159faa331aa082a0309e28810d4 Mon Sep 17 00:00:00 2001 From: Two Date: Tue, 16 Jun 2020 21:54:40 -0400 Subject: [PATCH 04/33] Update newticket.js --- commands/newticket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/newticket.js b/commands/newticket.js index 2229e53..1ee174a 100644 --- a/commands/newticket.js +++ b/commands/newticket.js @@ -114,7 +114,7 @@ module.exports = { await msg.react(Emoji_2); await msg.react(Emoji_3); let filter = (reaction, user) => { - if (user.bot) return; + if (user.id !== message.author.id) return; if (typeof reacted[ticketNumberID] !== "boolean") return; delete reacted[ticketNumberID]; if (reaction.emoji.name === Emoji_1) { From f7254c7ec7427a91f9d099f4fd6148487b1acde8 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sat, 20 Jun 2020 00:10:38 +0100 Subject: [PATCH 05/33] Push --- commands/newticket.js | 132 +++++++++++++++++++----------------- events/guildMemberAdd.js | 13 ++++ storage/SupportTickets.json | 2 +- storage/TicketID.json | 2 +- supportbot-config.yml | 9 +-- 5 files changed, 86 insertions(+), 72 deletions(-) create mode 100644 events/guildMemberAdd.js diff --git a/commands/newticket.js b/commands/newticket.js index cfd5fb0..1ee174a 100644 --- a/commands/newticket.js +++ b/commands/newticket.js @@ -7,6 +7,8 @@ const yaml = require('js-yaml'); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); const TicketNumberID = require('../utils/TicketNumber.js'); +const reacted = []; + module.exports = { name: supportbot.NewTicket, @@ -105,72 +107,78 @@ module.exports = { const Emoji_2 = supportbot.DepartmentEmoji_2; const Emoji_3 = supportbot.DepartmentEmoji_3; + reacted[ticketNumberID] = false; + if (supportbot.TicketDepartments === true) { - msg.react(Emoji_1).then(() => msg.react(Emoji_2)).then(() => msg.react(Emoji_3)) - - const filter = (reaction, user) => { + await msg.react(Emoji_1); + await msg.react(Emoji_2); + await msg.react(Emoji_3); + let filter = (reaction, user) => { + if (user.id !== message.author.id) return; + if (typeof reacted[ticketNumberID] !== "boolean") return; + delete reacted[ticketNumberID]; + 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 Department3 = 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 }); + } return [Emoji_1, Emoji_2, Emoji_3].includes(reaction.emoji.name) && user.id !== message.author.id; } - + msg.awaitReactions(filter, { + max: 4, + time: 60000, + errors: ['time'] + }).then(async collected => { + }); + 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); - + if (typeof reacted[ticketNumberID] == "boolean") { + delete reacted[ticketNumberID]; + //delete channel because didn't react in a minute + } + }, 60000); + } }); diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js new file mode 100644 index 0000000..fc6d6cc --- /dev/null +++ b/events/guildMemberAdd.js @@ -0,0 +1,13 @@ +// 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) => { + const SystemChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.SystemMessage_Channel) +}; \ No newline at end of file diff --git a/storage/SupportTickets.json b/storage/SupportTickets.json index 3eeb8dc..65ce4ab 100644 --- a/storage/SupportTickets.json +++ b/storage/SupportTickets.json @@ -1,4 +1,4 @@ { - "ticket": "ticket-0046", + "ticket": "ticket-0050", "id":419821884431925260 } \ No newline at end of file diff --git a/storage/TicketID.json b/storage/TicketID.json index 338ee2f..1e0e5d4 100644 --- a/storage/TicketID.json +++ b/storage/TicketID.json @@ -1,5 +1,5 @@ { "716992597377286145": { - "id": 47 + "id": 51 } } \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml index a2c0574..41857a1 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -145,11 +145,4 @@ NewTicket: "ticket" CloseTicket: "close" AddUser: "add" RemoveUser: "remove" -RenameTicket: "rename" - - - - - - - +RenameTicket: "rename" \ No newline at end of file From 4ae6dc3a69b811b217b600daad6128507ba02bb6 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sat, 20 Jun 2020 00:18:17 +0100 Subject: [PATCH 06/33] Update guildMemberAdd.js --- events/guildMemberAdd.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index fc6d6cc..61b4b35 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -9,5 +9,15 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = async (bot) => { + if (supportbot.SystemMessages === "true") { const SystemChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.SystemMessage_Channel) -}; \ No newline at end of file + + if (!SystemChannel) return; + + if (supportbot.SystemMessage_Embed === "true") { + const GuildAddMember = new Discord.MessageEmbed() + + } + + } +}; From f40aa9ed145e5da465cc6d82b44c473c9230973a Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sat, 20 Jun 2020 13:02:46 +0100 Subject: [PATCH 07/33] push --- events/guildMemberAdd.js | 36 ++++++++++++++++++++++++++++++++++++ package-lock.json | 6 +++--- package.json | 2 +- supportbot-config.yml | 18 ++++++++++++------ 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index fc6d6cc..170cefc 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -9,5 +9,41 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = async (bot) => { + if (supportbot.SystemMessages === "true") { const SystemChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.SystemMessage_Channel) + + if (!SystemChannel) return; + + if (supportbot.SystemMessage_Type === "embed") { + const GuildAddMember = new Discord.MessageEmbed() + .setTitle(supportbot.Welcome_Title) + .setDescription(supportbot.WelcomeMessage.replace(/%member%/g, message.member.user.username).replace(/%guildname%/g, guild.name)) + .setColor(supportbot.EmbedColour) + + if (supportbot.WelcomeMessage_Icon === "BOT") { + GuildAddMember.setThumbnail(message.author.displayAvatarURL()) + } + + if (supportbot.WelcomeMessage_Icon === "USER") { + GuildAddMember.setThumbnail(message.member.displayAvatarURL()) + } + + + if (supportbot.SystemMessage_EmbedFooter === "true") { + GuildAddMember.setFooter(supportbot.EmbedFooter) + } + + SystemChannel.send({ embed: GuildAddMember }); + + } + + if (supportbot.SystemMessage_Type === "normal") { + SystemChannel.send(supportbot.WelcomeMessage.replace(/%member%/g, message.member.user.username).replace(/%guildname%/g, guild.name)) + + if (supportbot.AutoRole === "true") { + member.roles.add(supportbot.AutoRole_Role) + } + } + + } }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b5daa9c..7b15878 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,9 +79,9 @@ "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==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", + "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" diff --git a/package.json b/package.json index 17deb5a..aadd509 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,6 @@ "license": "ISC", "dependencies": { "discord.js": "^12.2.0", - "js-yaml": "^3.13.1" + "js-yaml": "^3.14.0" } } diff --git a/supportbot-config.yml b/supportbot-config.yml index 41857a1..6054445 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -29,7 +29,9 @@ WarningColour: "#fca117" # Role Configuration -AutoRole: "Member" +AutoRole: "true" +# By setting "AutoRole to 'true' the bot will automatically apply the role below when members joins. Set to 'false' to disable this feature. +AutoRole_Role: "Member" Staff: "Support" Admin: "Admin" @@ -59,8 +61,6 @@ TicketDepartments: true 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: "📗" @@ -81,10 +81,15 @@ DepartmentRole_3: "Support" SystemMessages: "true" SystemMessage_Channel: "system-messages" -SystemMessages_Embed: "true" +SystemMessages_Type: "normal" +# There are 2 types of how you can send system messages, 'normal' or 'embed' -WelcomeMessage: "Hello %membertag%, Welcome to %guildname%!" -LeaveMessage: "Goodbye %membertag%, Thank you for visting %guildname%!" +WelcomeMessage: "Hello %member%, Welcome to %guildname%!" +WelcomeMessage_Icon: "USER" + +LeaveMessage: "Goodbye %member%, Thank you for visting %guildname%!" + +SystemMessage_EmbedFooter: "false" # LINKS Configuration @@ -94,6 +99,7 @@ LINKS: "Website": "https://www.example.com" "Store": "https://store.example.com" "Discord": "https://discord.gg/example" +# "Twitter": "https://twitter.com/example" # Suggestions Configuration From 63b08f8c126a760026abd4560253f2bde81a0483 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sat, 20 Jun 2020 16:10:27 +0100 Subject: [PATCH 08/33] guildMemberAdd Updated --- events/guildMemberAdd.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index 9b10285..bfe64bc 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -7,25 +7,25 @@ const fs = require("fs"); const yaml = require('js-yaml'); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -module.exports = async (bot) => { +module.exports = async (bot, member) => { + if (supportbot.SystemMessages === "true") { - const SystemChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.SystemMessage_Channel) + const SystemChannel = member.guild.channels.cache.find(channel => channel.name === supportbot.SystemMessage_Channel) if (!SystemChannel) return; if (supportbot.SystemMessage_Type === "embed") { const GuildAddMember = new Discord.MessageEmbed() .setTitle(supportbot.Welcome_Title) - .setDescription(supportbot.WelcomeMessage.replace(/%member%/g, message.member.user.username).replace(/%guildname%/g, guild.name)) + .setDescription(supportbot.WelcomeMessage.replace(/%member%/g, member.user.username).replace(/%guildname%/g, member.guild.name)) .setColor(supportbot.EmbedColour) if (supportbot.WelcomeMessage_Icon === "BOT") { - GuildAddMember.setThumbnail(message.author.displayAvatarURL()) + GuildAddMember.setThumbnail(bot.displayAvatarURL()) } if (supportbot.WelcomeMessage_Icon === "USER") { - GuildAddMember.setThumbnail(message.member.displayAvatarURL()) + GuildAddMember.setThumbnail(member.displayAvatarURL()) } @@ -38,7 +38,7 @@ module.exports = async (bot) => { } if (supportbot.SystemMessage_Type === "normal") { - SystemChannel.send(supportbot.WelcomeMessage.replace(/%member%/g, message.member.user.username).replace(/%guildname%/g, guild.name)) + SystemChannel.send(supportbot.WelcomeMessage.replace(/%member%/g, member.user.username).replace(/%guildname%/g, member.guild.name)) if (supportbot.AutoRole === "true") { member.roles.add(supportbot.AutoRole_Role) From ecd17a51df988243d57ced84d3fb8748ff4cbe68 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sun, 21 Jun 2020 12:36:48 +0100 Subject: [PATCH 09/33] guildMemberAdd Updated --- events/guildMemberAdd.js | 12 ++++++------ package-lock.json | 4 +--- package.json | 25 +++++++++++++++++-------- supportbot-config.yml | 3 ++- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index bfe64bc..5142ef3 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -14,6 +14,9 @@ module.exports = async (bot, member) => { if (!SystemChannel) return; + console.log(`[${supportbot.Bot_Name}]: ${member.user.username} has joined ${member.guild.name}!`) + console.log(supportbot.AutoRole_Role) + if (supportbot.SystemMessage_Type === "embed") { const GuildAddMember = new Discord.MessageEmbed() .setTitle(supportbot.Welcome_Title) @@ -21,11 +24,11 @@ module.exports = async (bot, member) => { .setColor(supportbot.EmbedColour) if (supportbot.WelcomeMessage_Icon === "BOT") { - GuildAddMember.setThumbnail(bot.displayAvatarURL()) + GuildAddMember.setThumbnail(bot.user.displayAvatarURL()) } if (supportbot.WelcomeMessage_Icon === "USER") { - GuildAddMember.setThumbnail(member.displayAvatarURL()) + GuildAddMember.setThumbnail(member.user.displayAvatarURL()) } @@ -40,10 +43,7 @@ module.exports = async (bot, member) => { if (supportbot.SystemMessage_Type === "normal") { SystemChannel.send(supportbot.WelcomeMessage.replace(/%member%/g, member.user.username).replace(/%guildname%/g, member.guild.name)) - if (supportbot.AutoRole === "true") { - member.roles.add(supportbot.AutoRole_Role) - } } - + } }; diff --git a/package-lock.json b/package-lock.json index 7b15878..2fd0c32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,6 @@ { - "name": "supportbot", - "version": "1.0.0", - "lockfileVersion": 1, "requires": true, + "lockfileVersion": 1, "dependencies": { "@discordjs/collection": { "version": "0.1.5", diff --git a/package.json b/package.json index aadd509..90261de 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,24 @@ { "name": "supportbot", - "version": "1.0.0", - "description": "A self hosted discord support bot. SUPPORTBOT v6 GO CRAZYYYY", + "version": "6.0.0", + "description": "SupportBot | #1 Self-Hosted Ticket Bot", "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", "dependencies": { "discord.js": "^12.2.0", "js-yaml": "^3.14.0" - } + }, + "devDependencies": {}, + "scripts": { + "test": "help" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/1tzemerald/SupportBot.git" + }, + "author": "Emerald Services", + "license": "MIT", + "bugs": { + "url": "https://github.com/1tzemerald/SupportBot/issues" + }, + "homepage": "https://github.com/1tzemerald/SupportBot#readme" } diff --git a/supportbot-config.yml b/supportbot-config.yml index 6054445..80b6a8d 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -81,9 +81,10 @@ DepartmentRole_3: "Support" SystemMessages: "true" SystemMessage_Channel: "system-messages" -SystemMessages_Type: "normal" +SystemMessage_Type: "embed" # There are 2 types of how you can send system messages, 'normal' or 'embed' +Welcome_Title: "Welcome" WelcomeMessage: "Hello %member%, Welcome to %guildname%!" WelcomeMessage_Icon: "USER" From ff7ed499059ac50525a00df5bcd89bed54aa5268 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sun, 21 Jun 2020 15:56:16 +0100 Subject: [PATCH 10/33] guildMemberRemove added --- commands/close.js | 9 ++++++- events/guildMemberAdd.js | 4 ++-- events/guildMemberRemove.js | 48 +++++++++++++++++++++++++++++++++++++ package-lock.json | 4 +++- storage/SupportTickets.json | 4 ++-- storage/TicketID.json | 2 +- supportbot-config.yml | 5 ++-- 7 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 events/guildMemberRemove.js diff --git a/commands/close.js b/commands/close.js index 2a5f340..006cc29 100644 --- a/commands/close.js +++ b/commands/close.js @@ -12,7 +12,14 @@ module.exports = { name: "bob", execute(message, args) { + console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.CloseTicket}!`); - message.channel.delete() + if (supportbot.Close === "staff") { + member.roles.cache.has(``) + } + + if (supportbot.Close === "user") { + + } } }; \ No newline at end of file diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index 5142ef3..e4ffa83 100644 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -23,11 +23,11 @@ module.exports = async (bot, member) => { .setDescription(supportbot.WelcomeMessage.replace(/%member%/g, member.user.username).replace(/%guildname%/g, member.guild.name)) .setColor(supportbot.EmbedColour) - if (supportbot.WelcomeMessage_Icon === "BOT") { + if (supportbot.SystemMessage_Icon === "BOT") { GuildAddMember.setThumbnail(bot.user.displayAvatarURL()) } - if (supportbot.WelcomeMessage_Icon === "USER") { + if (supportbot.SystemMessage_Icon === "USER") { GuildAddMember.setThumbnail(member.user.displayAvatarURL()) } diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js new file mode 100644 index 0000000..168a4e6 --- /dev/null +++ b/events/guildMemberRemove.js @@ -0,0 +1,48 @@ +// 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, member) => { + + if (supportbot.SystemMessages === "true") { + const SystemChannel = member.guild.channels.cache.find(channel => channel.name === supportbot.SystemMessage_Channel) + + if (!SystemChannel) return; + + console.log(`[${supportbot.Bot_Name}]: ${member.user.username} has left ${member.guild.name}!`) + + if (supportbot.SystemMessage_Type === "embed") { + const GuildRemoveMember = new Discord.MessageEmbed() + .setTitle(supportbot.Leave_Title) + .setDescription(supportbot.LeaveMessage.replace(/%member%/g, member.user.username).replace(/%guildname%/g, member.guild.name)) + .setColor(supportbot.EmbedColour) + + if (supportbot.SystemMessage_Icon === "BOT") { + GuildAddMember.setThumbnail(bot.user.displayAvatarURL()) + } + + if (supportbot.SystemMessage_Icon === "USER") { + GuildAddMember.setThumbnail(member.user.displayAvatarURL()) + } + + + if (supportbot.SystemMessage_EmbedFooter === "true") { + GuildAddMember.setFooter(supportbot.EmbedFooter) + } + + SystemChannel.send({ embed: GuildRemoveMember }); + + } + + if (supportbot.SystemMessage_Type === "normal") { + SystemChannel.send(supportbot.LeaveMessage.replace(/%member%/g, member.user.username).replace(/%guildname%/g, member.guild.name)) + + } + + } +}; diff --git a/package-lock.json b/package-lock.json index 2fd0c32..7540c76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,8 @@ { - "requires": true, + "name": "supportbot", + "version": "6.0.0", "lockfileVersion": 1, + "requires": true, "dependencies": { "@discordjs/collection": { "version": "0.1.5", diff --git a/storage/SupportTickets.json b/storage/SupportTickets.json index 65ce4ab..3078a8d 100644 --- a/storage/SupportTickets.json +++ b/storage/SupportTickets.json @@ -1,4 +1,4 @@ { - "ticket": "ticket-0050", - "id":419821884431925260 + "ticket": "ticket-0054", + "id":276497792526974996 } \ No newline at end of file diff --git a/storage/TicketID.json b/storage/TicketID.json index 1e0e5d4..1e4e615 100644 --- a/storage/TicketID.json +++ b/storage/TicketID.json @@ -1,5 +1,5 @@ { "716992597377286145": { - "id": 51 + "id": 55 } } \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml index 80b6a8d..17ef23d 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -83,11 +83,12 @@ SystemMessages: "true" SystemMessage_Channel: "system-messages" SystemMessage_Type: "embed" # There are 2 types of how you can send system messages, 'normal' or 'embed' +SystemMessage_Icon: "USER" -Welcome_Title: "Welcome" +Welcome_Title: "User Joined!" WelcomeMessage: "Hello %member%, Welcome to %guildname%!" -WelcomeMessage_Icon: "USER" +Leave_Title: "User Left!" LeaveMessage: "Goodbye %member%, Thank you for visting %guildname%!" SystemMessage_EmbedFooter: "false" From cf99209887ad896ad3586cf1934fce5a2e9440cc Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Wed, 24 Jun 2020 09:50:14 +0100 Subject: [PATCH 11/33] Close Ticket --- commands/close.js | 22 +++++++++++++++++----- supportbot-config.yml | 8 ++++++++ test | 8 ++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 test diff --git a/commands/close.js b/commands/close.js index 006cc29..80413a0 100644 --- a/commands/close.js +++ b/commands/close.js @@ -13,13 +13,25 @@ module.exports = { execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.CloseTicket}!`); - - if (supportbot.Close === "staff") { - member.roles.cache.has(``) - } - if (supportbot.Close === "user") { + if (!message.channel.name.startsWith( `${TicketChannel}-` )) { + const Exists = 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: Exists }); + + return; } + + if (supportbot.CloseConfirmation === "true") { + const CloseTicketRequest = new Discord.MessageEmbed() + .setDescription(`**${supportbot.ClosingTicket}**`) + .addField("Please confirm by repeating the following word..", `**${supportbot.ClosingConfirmation_Word}**`) + + } + + } }; \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml index 17ef23d..ee45c21 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -18,6 +18,9 @@ Bot_Name: "SupportBot DEV" BotActivity: "SB-6.0 dev-0.1" ActivityType: "PLAYING" +ShowErrorCodes: "true" +# This feature will show supportbot error codes such as "SB-01" + # Embed Configuration EmbedColour: "#04b545" @@ -53,6 +56,11 @@ TicketCreatedAlert: ":ticket: Your support ticket has been created: <#%ticketid% TicketPanel: true ReactionForTicket: 🎫 +ClosingTicket: ":warning: You have requested to close your support ticket." +ClosingConfirmation_Word: "confirm" +CloseConfirmation: true +Transcripts: true + # Ticket Department Configuration TicketDepartments: true diff --git a/test b/test new file mode 100644 index 0000000..23e74ae --- /dev/null +++ b/test @@ -0,0 +1,8 @@ + 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`) + .setColor(supportbot.ErrorColour); + + if (supportbot.ShowErrorCodes === "true") { + rolerequired.addField("Error Code", "SB-02") + } \ No newline at end of file From 72a02bf6d2c8c9d6cd30e8ef3d9a9ea73703471b Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sat, 4 Jul 2020 00:54:34 +0100 Subject: [PATCH 12/33] Close.js updated --- commands/close.js | 117 ++++++++++++++++++++++++++++++++++-- commands/newticket.js | 23 +++++-- storage/SupportTickets.json | 4 +- storage/TicketID.json | 2 +- supportbot-config.yml | 13 ++-- test | 8 --- 6 files changed, 140 insertions(+), 27 deletions(-) delete mode 100644 test diff --git a/commands/close.js b/commands/close.js index 80413a0..5fa9c2f 100644 --- a/commands/close.js +++ b/commands/close.js @@ -9,12 +9,12 @@ const { execute } = require("./help"); const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); module.exports = { - name: "bob", + name: supportbot.CloseTicket, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.CloseTicket}!`); - if (!message.channel.name.startsWith( `${TicketChannel}-` )) { + if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("Incorrect Channel") .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) @@ -27,11 +27,120 @@ module.exports = { if (supportbot.CloseConfirmation === "true") { const CloseTicketRequest = new Discord.MessageEmbed() - .setDescription(`**${supportbot.ClosingTicket}**`) - .addField("Please confirm by repeating the following word..", `**${supportbot.ClosingConfirmation_Word}**`) + .setTitle(`**${supportbot.ClosingTicket}**`) + .setDescription(`Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` `) + .setColor(supportbot.EmbedColour); + + message.channel.send(CloseTicketRequest).then(m => { + message.channel.awaitMessages( response => response.content.toLowerCase() === supportbot.ClosingConfirmation_Word, { + max: 1, + time: 20000, + errors: [ 'time' ], + + + }).then( collected => { + let logChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog); + let user = message.author; + let reason = args.join(" ") || "No Reason Provided."; + + let name = message.channel.name; + let ticketChannel = message.channel; + + message.channel.send(`**${supportbot.ClosingTicket}**`) + + .then(() => { + const logEmbed = new Discord.MessageEmbed() + .setTitle(supportbot.TranscriptTitle) + .setColor(supportbot.EmbedColour) + .setFooter(supportbot.EmbedFooter) + .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`; + } + }); + + logChannel.send(logEmbed).catch(err => { + message.reply(err) + }) + + logChannel.send( new Discord.MessageAttachment( Buffer.from( txt ), `${name}.txt` ) ); + + message.channel.delete(); + + }) + }) + + }) + + }).catch( () => { + m.edit('The request to close the ticket has timed out.').then( m2 => m2.delete( 3000 ) ); + }); } + if (supportbot.CloseConfirmation === "false") { + + let logChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog); + let user = message.author; + let reason = args.join(" ") || "No Reason Provided."; + + let name = message.channel.name; + let ticketChannel = message.channel; + + message.channel.send(`**${supportbot.ClosingTicket}**`) + + .then(() => { + const logEmbed = new Discord.MessageEmbed() + .setTitle(supportbot.TranscriptTitle) + .setColor(supportbot.EmbedColour) + .setFooter(supportbot.EmbedFooter) + .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`; + } + }); + + logChannel.send(logEmbed).catch(err => { + message.reply(err) + }) + + logChannel.send( new Discord.MessageAttachment( Buffer.from( txt ), `${name}.txt` ) ); + + message.channel.delete(); + + }) + + }).catch( () => { + m.edit('The request to close the ticket has timed out.').then( m2 => m2.delete( 3000 ) ); + }); + + } } }; \ No newline at end of file diff --git a/commands/newticket.js b/commands/newticket.js index 1ee174a..3995ba3 100644 --- a/commands/newticket.js +++ b/commands/newticket.js @@ -97,7 +97,7 @@ module.exports = { } - if (supportbot.TicketDepartments === true) { + 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}**` }) } @@ -109,7 +109,7 @@ module.exports = { reacted[ticketNumberID] = false; - if (supportbot.TicketDepartments === true) { + if (supportbot.TicketDepartments === "true") { await msg.react(Emoji_1); await msg.react(Emoji_2); await msg.react(Emoji_3); @@ -122,10 +122,14 @@ module.exports = { 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) { + if (supportbot.AllowStaff === "true") { SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) } + if (supportbot.AllowStaff === "false") { + SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: false, 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) @@ -138,9 +142,13 @@ module.exports = { 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) { + if (supportbot.AllowStaff === "true") { SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) } + + if (supportbot.AllowStaff === "false") { + SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: false, 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.`) @@ -153,10 +161,15 @@ module.exports = { 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, }) + SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: false, READ_MESSAGES: true, SEND_MESSAGES: true, }) - if (supportbot.AllowStaff === true) { + if (supportbot.AllowStaff === "true") { SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, }) } + + if (supportbot.AllowStaff === "false") { + SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: false, READ_MESSAGES: true, SEND_MESSAGES: true, }) + } const Department3 = new Discord.MessageEmbed() .setTitle(`> Thank for reaching out to the **${supportbot.DepartmentTitle_3} Department**. Please provide us information regarding your query.`) diff --git a/storage/SupportTickets.json b/storage/SupportTickets.json index 3078a8d..0bc4123 100644 --- a/storage/SupportTickets.json +++ b/storage/SupportTickets.json @@ -1,4 +1,4 @@ { - "ticket": "ticket-0054", - "id":276497792526974996 + "ticket": "ticket-0058", + "id":419821884431925260 } \ No newline at end of file diff --git a/storage/TicketID.json b/storage/TicketID.json index 1e4e615..9f38e34 100644 --- a/storage/TicketID.json +++ b/storage/TicketID.json @@ -1,5 +1,5 @@ { "716992597377286145": { - "id": 55 + "id": 59 } } \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml index ee45c21..25f4482 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -46,27 +46,26 @@ TicketCategory: "Tickets" TicketLog: "ticket-logs" TranscriptLog: "transcripts" TicketSubject: "description" +# TicketSuvject: "description" means that the subject (reason) of the ticket will be displayed upon the channel description if set to "embed" it will be displayed within the embed. 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: 🎫 +TranscriptTitle: "Ticket Transcript" ClosingTicket: ":warning: You have requested to close your support ticket." ClosingConfirmation_Word: "confirm" -CloseConfirmation: true -Transcripts: true +CloseConfirmation: "true" +# CloseConfirmation to true will make users confirm that they want to close a their ticket, settings to false will just close the ticket. # Ticket Department Configuration -TicketDepartments: true +TicketDepartments: "true" # This option enable or disable the ticket departments. If set false Ticket Departments will not work -AllowStaff: true +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. DepartmentEmoji_1: "🙋" diff --git a/test b/test deleted file mode 100644 index 23e74ae..0000000 --- a/test +++ /dev/null @@ -1,8 +0,0 @@ - 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`) - .setColor(supportbot.ErrorColour); - - if (supportbot.ShowErrorCodes === "true") { - rolerequired.addField("Error Code", "SB-02") - } \ No newline at end of file From 94db6cff7b6e9d622aa952003bf0e21e98fd3991 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Fri, 10 Jul 2020 18:55:03 +0100 Subject: [PATCH 13/33] Create addUser.js --- commands/addUser.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 commands/addUser.js diff --git a/commands/addUser.js b/commands/addUser.js new file mode 100644 index 0000000..18d884a --- /dev/null +++ b/commands/addUser.js @@ -0,0 +1,44 @@ +// SupportBot 6.0, Created by Emerald Services +// Add User + +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 = { + name: supportbot.AddUser, + + execute(message, args) { + console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.AddUser}!`); + + let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.StaffRole); + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(":warning: **Err!** You do not have the correct permissions to use this command.") + .setColor(supportbot.WarningColour) + message.channel.send({ embed: NoPerms }); + + if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { + const Exists = 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: Exists }); + + return; + } + + let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); + const UserNotExist = new Discord.MessageEmbed() + .setTitle("User Not Found!") + .setDescription(`:x: **Error!** This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.AddUser} \``) + .setColor(supportbot.ErrorColor) + + if (!rUser) return message.channel.send({ embed: UserNotExist }); + + + + } +}; \ No newline at end of file From f0a791e354259aa6535153f6a1552ffe06d5f4f9 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Fri, 10 Jul 2020 20:48:41 +0100 Subject: [PATCH 14/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2743f94..610fc32 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The #1 self-hosted discord ticket bot ``` -## UPPORTBOT SUPPORTED VERSIONS +## SUPPORTBOT SUPPORTED VERSIONS | SupportBot | Status | Supported | |------------|-----------|--------------| From 59dd291dc65f7772e213e6ff536617b09b26d373 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Fri, 10 Jul 2020 20:55:02 +0100 Subject: [PATCH 15/33] Update addUser.js --- commands/addUser.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/commands/addUser.js b/commands/addUser.js index 18d884a..9fd4eda 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -37,8 +37,19 @@ module.exports = { .setColor(supportbot.ErrorColor) if (!rUser) return message.channel.send({ embed: UserNotExist }); - - - + + message.channel.updateOverwrite(rUser, { + VIEW_CHANNEL: true, + CREATE_INVITE: false, + SEND_MESSAGES: true, + READ_MESSAGES: true + }); + + const Complete = new Discord.MessageEmbed() + .setTitle("User Added!") + .setDescription(`👍 ${rUser} has been added to this ticket`) + .setTimestamp() + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: Complete }); } -}; \ No newline at end of file +}; From 05a772eee288b050a8a18b18f53148cf253b4f96 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Fri, 10 Jul 2020 20:56:40 +0100 Subject: [PATCH 16/33] Create removeUser.js --- commands/removeUser.js | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 commands/removeUser.js diff --git a/commands/removeUser.js b/commands/removeUser.js new file mode 100644 index 0000000..7fee71b --- /dev/null +++ b/commands/removeUser.js @@ -0,0 +1,55 @@ +// SupportBot 6.0, Created by Emerald Services +// Add User + +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 = { + name: supportbot.RemoveUser, + + execute(message, args) { + console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.RemoveUser}!`); + + let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff); + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(":warning: **Err!** You do not have the correct permissions to use this command.") + .setColor(supportbot.WarningColour) + message.channel.send({ embed: NoPerms }); + + if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { + const Exists = 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: Exists }); + + return; + } + + let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); + const UserNotExist = new Discord.MessageEmbed() + .setTitle("User Not Found!") + .setDescription(`:x: **Error!** This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.RemoveUser} \``) + .setColor(supportbot.ErrorColor) + + if (!rUser) return message.channel.send({ embed: UserNotExist }); + + message.channel.updateOverwrite(rUser, { + VIEW_CHANNEL: false, + CREATE_INVITE: false, + SEND_MESSAGES: false, + READ_MESSAGES: false + }); + + const Complete = new Discord.MessageEmbed() + .setTitle("User Removed!") + .setDescription(`👍 ${rUser} has been removed from this ticket`) + .setTimestamp() + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: Complete }); + } +}; From dcc00d8d1fc7a93b8b75ae442528c92d751320ec Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sat, 11 Jul 2020 13:17:57 +0100 Subject: [PATCH 17/33] Update --- commands/addUser.js | 22 +++++++++++++---- commands/announce.js | 14 +++++------ commands/removeUser.js | 55 ++++++++++++++++++++++++++++++++++++++++++ supportbot-config.yml | 21 ++++++++-------- 4 files changed, 89 insertions(+), 23 deletions(-) create mode 100644 commands/removeUser.js diff --git a/commands/addUser.js b/commands/addUser.js index 18d884a..70c679a 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -13,10 +13,11 @@ module.exports = { execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.AddUser}!`); - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.StaffRole); + let SupportStaff = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff); + const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(":warning: **Err!** You do not have the correct permissions to use this command.") + .setDescription(`:warning: **Err!** You do not have the correct permissions to use this command.\n\nRole Required: \`${supportbot.SupportStaff}\``) .setColor(supportbot.WarningColour) message.channel.send({ embed: NoPerms }); @@ -37,8 +38,19 @@ module.exports = { .setColor(supportbot.ErrorColor) if (!rUser) return message.channel.send({ embed: UserNotExist }); - - - + + message.channel.updateOverwrite(rUser, { + VIEW_CHANNEL: true, + CREATE_INVITE: false, + SEND_MESSAGES: true, + READ_MESSAGES: true + }); + + const Complete = new Discord.MessageEmbed() + .setTitle("User Added!") + .setDescription(`👍 ${rUser} has been added to this ticket`) + .setTimestamp() + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: Complete }); } }; \ No newline at end of file diff --git a/commands/announce.js b/commands/announce.js index f41df48..3d57469 100644 --- a/commands/announce.js +++ b/commands/announce.js @@ -16,19 +16,19 @@ module.exports = { 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\``) + .setTitle("Invalid Channel") + .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}`) .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 NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(`:warning: **Err!** You do not have the correct permissions to use this command.\n\nRole Required: \`${supportbot.serverAdmins}\``) + .setColor(supportbot.WarningColour) + message.channel.send({ embed: NoPerms }); const embed = new Discord.MessageEmbed() diff --git a/commands/removeUser.js b/commands/removeUser.js new file mode 100644 index 0000000..ae428a3 --- /dev/null +++ b/commands/removeUser.js @@ -0,0 +1,55 @@ +// SupportBot 6.0, Created by Emerald Services +// Remove User + +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 = { + name: supportbot.RemoveUser, + + execute(message, args) { + console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.RemoveUser}!`); + + let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff); + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(":warning: **Err!** You do not have the correct permissions to use this command.") + .setColor(supportbot.WarningColour) + message.channel.send({ embed: NoPerms }); + + if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { + const Exists = 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: Exists }); + + return; + } + + let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); + const UserNotExist = new Discord.MessageEmbed() + .setTitle("User Not Found!") + .setDescription(`:x: **Error!** This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.RemoveUser} \``) + .setColor(supportbot.ErrorColor) + + if (!rUser) return message.channel.send({ embed: UserNotExist }); + + message.channel.updateOverwrite(rUser, { + VIEW_CHANNEL: false, + CREATE_INVITE: false, + SEND_MESSAGES: false, + READ_MESSAGES: false + }); + + const Complete = new Discord.MessageEmbed() + .setTitle("User Removed!") + .setDescription(`👍 ${rUser} has been removed from this ticket`) + .setTimestamp() + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: Complete }); + } +}; \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml index 25f4482..e1f7c46 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -35,6 +35,7 @@ WarningColour: "#fca117" AutoRole: "true" # By setting "AutoRole to 'true' the bot will automatically apply the role below when members joins. Set to 'false' to disable this feature. AutoRole_Role: "Member" +LockdownRole: "@everyone" Staff: "Support" Admin: "Admin" @@ -144,20 +145,18 @@ 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" \ No newline at end of file +RenameTicket: "rename" + +# Staff Command Configuration + +SayCommand: "say" + +# Admin Command Configuration + +AnnounceCommand: "announce" From e3576b17b1c511e63aad2f0ceae77c746e890bef Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Tue, 14 Jul 2020 19:17:40 +0100 Subject: [PATCH 18/33] Updated --- commands/addUser.js | 21 +++++++++------- commands/announce.js | 9 ++++--- commands/botSay.js | 50 +++++++++++++++++++++++++++++++++++++ commands/close.js | 5 ++-- commands/help.js | 38 +++++++++++++++++----------- commands/links.js | 1 + commands/newticket.js | 3 ++- commands/ping.js | 1 + commands/removeUser.js | 23 +++++++++-------- commands/suggest.js | 5 ++-- package-lock.json | 6 ++--- storage/SupportTickets.json | 2 +- storage/TicketID.json | 2 +- supportbot-config.yml | 28 +++++++++++++++++++-- 14 files changed, 145 insertions(+), 49 deletions(-) create mode 100644 commands/botSay.js diff --git a/commands/addUser.js b/commands/addUser.js index d5f249c..e9e8d19 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -9,22 +9,25 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.AddUser, + description: supportbot.AddUserDesc, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.AddUser}!`); - let SupportStaff = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff); + let SupportStaff = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff, supportbot.Admin); const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(`:warning: **Err!** You do not have the correct permissions to use this command.\n\nRole Required: \`${supportbot.SupportStaff}\``) - .setColor(supportbot.WarningColour) - message.channel.send({ embed: NoPerms }); + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${SupportStaff.name}\``) + .setColor(supportbot.ErrorColour) + + if (!message.member.roles.cache.has(SupportStaff.id)) + return message.channel.send({ embed: NoPerms }); if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) .setColor(supportbot.WarningColour); message.channel.send({ embed: Exists }); @@ -34,8 +37,8 @@ module.exports = { let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); const UserNotExist = new Discord.MessageEmbed() .setTitle("User Not Found!") - .setDescription(`:x: **Error!** This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.AddUser} \``) - .setColor(supportbot.ErrorColor) + .setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${supportbot.AddUser} \``) + .setColor(supportbot.ErrorColour) if (!rUser) return message.channel.send({ embed: UserNotExist }); @@ -48,7 +51,7 @@ module.exports = { const Complete = new Discord.MessageEmbed() .setTitle("User Added!") - .setDescription(`👍 ${rUser} has been added to this ticket`) + .setDescription(supportbot.AddedUser.replace(/%user%/g, rUser.id)) .setTimestamp() .setColor(supportbot.EmbedColour) message.channel.send({ embed: Complete }); diff --git a/commands/announce.js b/commands/announce.js index 3d57469..50205ce 100644 --- a/commands/announce.js +++ b/commands/announce.js @@ -10,6 +10,7 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.AnnounceCommand, + description: supportbot.AnnounceDesc, execute(message, args) { @@ -17,7 +18,7 @@ module.exports = { const errornochannel = new Discord.MessageEmbed() .setTitle("Invalid Channel") - .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}`) + .setDescription(`${supportbot.InvalidChannel}\n\nChannel Required: \`${supportbot.AnnouncementChannel}`) .setColor(supportbot.ErrorColour); if(!locateChannel) return message.channel.send({ embed: errornochannel }); @@ -26,9 +27,11 @@ module.exports = { const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(`:warning: **Err!** You do not have the correct permissions to use this command.\n\nRole Required: \`${supportbot.serverAdmins}\``) + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${serverAdmins.name}\``) .setColor(supportbot.WarningColour) - message.channel.send({ embed: NoPerms }); + + if (!message.member.roles.cache.has(serverAdmins.id)) + return message.channel.send({ embed: NoPerms }); const embed = new Discord.MessageEmbed() diff --git a/commands/botSay.js b/commands/botSay.js new file mode 100644 index 0000000..c90df2c --- /dev/null +++ b/commands/botSay.js @@ -0,0 +1,50 @@ +// SupportBot 6.0, Created by Emerald Services +// Say Command + +const Discord = require("discord.js"); +const fs = require("fs"); + +const yaml = require('js-yaml'); +const { execute } = require("./help"); +const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); + +module.exports = { + name: supportbot.BotSay, + description: supportbot.BotSayDesc, + + execute(message, args) { + + let SupportStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Staff); + + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${SupportStaff.name}\``) + .setColor(supportbot.WarningColour) + + if (!message.member.roles.cache.has(SupportStaff.id)) + return message.channel.send({ embed: NoPerms }); + + + const embed = new Discord.MessageEmbed() + .setDescription(`> **What would you like me to say!**`) + .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() + .setDescription(announcement) + .setColor(supportbot.EmbedColour) + + message.channel.send({ embed: AnnouncementEmbed }) + }) + + } + +}; \ No newline at end of file diff --git a/commands/close.js b/commands/close.js index 5fa9c2f..d45fae6 100644 --- a/commands/close.js +++ b/commands/close.js @@ -10,14 +10,15 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.CloseTicket, + description: supportbot.CloseTicketDesc, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.CloseTicket}!`); if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) .setColor(supportbot.WarningColour); message.channel.send({ embed: Exists }); diff --git a/commands/help.js b/commands/help.js index 7cac1a5..0a029e0 100644 --- a/commands/help.js +++ b/commands/help.js @@ -9,26 +9,24 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.HelpCommand, + description: supportbot.HelpDesc, 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`; + generalCommands += `**${supportbot.Prefix}${supportbot.HelpCommand}** ${supportbot.HelpDesc}\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.LinksCommand}** ${supportbot.LinkDesc}\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.SuggestCommand}** ${supportbot.SuggestionDesc}\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.PingCommand}** ${supportbot.PingDesc}\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` + supportCommands += `**${supportbot.Prefix}${supportbot.NewTicket} [reason]** ${supportbot.NewTicketDesc}\n` + supportCommands += `**${supportbot.Prefix}${supportbot.CloseTicket} [reason]** ${supportbot.CloseTicketDesc}\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` + staffCommands += `**${supportbot.Prefix}${supportbot.AddUser} ** ${supportbot.AddUserDesc}\n` + staffCommands += `**${supportbot.Prefix}${supportbot.RemoveUser} ** ${supportbot.RemoveUserDesc}\n` + staffCommands += `**${supportbot.Prefix}${supportbot.BotSayCommand}** ${supportbot.BotSayDesc}\n` + staffCommands += `**${supportbot.Prefix}${supportbot.AnnounceCommand}** ${supportbot.AnnounceDesc}\n` const HelpCommandEmbed = new Discord.MessageEmbed() .setTitle(supportbot.Bot_Name) @@ -37,13 +35,23 @@ module.exports = { .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 }, ) .setColor(supportbot.EmbedColour) .setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL()); + if (message.member.roles.cache.some(role => role.name === supportbot.Staff, supportbot.Admin)) { + HelpCommandEmbed.addFields( + { name: '🔑 Staff Commands', value: `${staffCommands}\n`, inline: false }, + ) + } + + if (message.member.roles.cache.some(role => role.name === supportbot.Admin)) { + HelpCommandEmbed.addFields( + { name: '🔑 Staff Commands', value: `${staffCommands}\n`, inline: false }, + ) + } + message.channel.send({ embed: HelpCommandEmbed }); } }; \ No newline at end of file diff --git a/commands/links.js b/commands/links.js index f17a9c9..4282cad 100644 --- a/commands/links.js +++ b/commands/links.js @@ -10,6 +10,7 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.LinksCommand, + description: supportbot.LinksDesc, execute(message, args) { diff --git a/commands/newticket.js b/commands/newticket.js index 3995ba3..7d8514f 100644 --- a/commands/newticket.js +++ b/commands/newticket.js @@ -11,6 +11,7 @@ const reacted = []; module.exports = { name: supportbot.NewTicket, + description: supportbot.NewTicketDesc, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.NewTicket}!`); @@ -24,7 +25,7 @@ module.exports = { // Ticket Exists const TicketExists = new Discord.MessageEmbed() .setTitle("Ticket Exists!") - .setDescription(":no_entry_sign: This ticket cannot be opened, It already exists!") + .setDescription(`${supportbot.TicketExists}`) .setColor(supportbot.WarningColour) if (message.guild.channels.cache.find(SupportTicket => SupportTicket.name === `${supportbot.TicketChannel}-${ticketNumberID}`)) diff --git a/commands/ping.js b/commands/ping.js index 5a6548e..e69206c 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -9,6 +9,7 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.PingCommand, + description: supportbot.PingDesc, execute(message, args) { let ping = Date.now() - message.createdTimestamp + " ms"; diff --git a/commands/removeUser.js b/commands/removeUser.js index 7fee71b..5b14b0f 100644 --- a/commands/removeUser.js +++ b/commands/removeUser.js @@ -9,21 +9,24 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.RemoveUser, + description: supportbot.RemoveUserDesc, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.RemoveUser}!`); - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff); - const NoPerms = new Discord.MessageEmbed() - .setTitle("Invalid Permissions!") - .setDescription(":warning: **Err!** You do not have the correct permissions to use this command.") - .setColor(supportbot.WarningColour) - message.channel.send({ embed: NoPerms }); + let SupportStaff = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff); + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${SupportStaff.name}\``) + .setColor(supportbot.ErrorColour) + + if (!message.member.roles.cache.has(SupportStaff.id)) + return message.channel.send({ embed: NoPerms }); if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) .setColor(supportbot.WarningColour); message.channel.send({ embed: Exists }); @@ -33,7 +36,7 @@ module.exports = { let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); const UserNotExist = new Discord.MessageEmbed() .setTitle("User Not Found!") - .setDescription(`:x: **Error!** This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.RemoveUser} \``) + .setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${supportbot.RemoveUser} \``) .setColor(supportbot.ErrorColor) if (!rUser) return message.channel.send({ embed: UserNotExist }); @@ -47,7 +50,7 @@ module.exports = { const Complete = new Discord.MessageEmbed() .setTitle("User Removed!") - .setDescription(`👍 ${rUser} has been removed from this ticket`) + .setDescription(supportbot.RemovedUser.replace(/%user%/g, rUser.id)) .setTimestamp() .setColor(supportbot.EmbedColour) message.channel.send({ embed: Complete }); diff --git a/commands/suggest.js b/commands/suggest.js index 64aadb0..7ffd398 100644 --- a/commands/suggest.js +++ b/commands/suggest.js @@ -9,13 +9,14 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.SuggestCommand, + description: supportbot.SuggestionDesc, 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\``) + .setTitle("Invalid Channel") + .setDescription(`${supportbot.InvalidChannel}\n\nChannel Required: \`${supportbot.SuggestionChannel}\``) .setColor(supportbot.ErrorColour); if(!locateChannel) return message.channel.send({ embed: errornochannel }); diff --git a/package-lock.json b/package-lock.json index 7540c76..76dde51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -126,9 +126,9 @@ "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, "ws": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", - "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==" + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" } } } diff --git a/storage/SupportTickets.json b/storage/SupportTickets.json index 0bc4123..7635a24 100644 --- a/storage/SupportTickets.json +++ b/storage/SupportTickets.json @@ -1,4 +1,4 @@ { - "ticket": "ticket-0058", + "ticket": "ticket-0061", "id":419821884431925260 } \ No newline at end of file diff --git a/storage/TicketID.json b/storage/TicketID.json index 9f38e34..0ece568 100644 --- a/storage/TicketID.json +++ b/storage/TicketID.json @@ -1,5 +1,5 @@ { "716992597377286145": { - "id": 59 + "id": 62 } } \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml index e1f7c46..239e0c9 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -11,7 +11,7 @@ # General Bot Configuration -Token: "TOKEN" +Token: "NjcyMTU5MjQyNjg5NzA4MDUz.XwnBpg.6eCCVRv4m-aVPJuppHWNxpxpRs0" Prefix: "!!" Bot_Name: "SupportBot DEV" @@ -56,6 +56,9 @@ NoTicketSubject: "No Reason Provided!" TicketCreatedAlert: ":ticket: Your support ticket has been created: <#%ticketid%>" TranscriptTitle: "Ticket Transcript" +AddedUser: "👍 <@%user%> has been added to this ticket" +RemovedUser: "👍 <@%user%> has been removed from this ticket" + ClosingTicket: ":warning: You have requested to close your support ticket." ClosingConfirmation_Word: "confirm" CloseConfirmation: "true" @@ -155,8 +158,29 @@ RenameTicket: "rename" # Staff Command Configuration -SayCommand: "say" +BotSay: "say" # Admin Command Configuration AnnounceCommand: "announce" + +# Commmand Descriptions + +NewTicketDesc: "Create a new support ticket" +AnnounceDesc: "Create a server announcement" +CloseTicketDesc: "Close your support ticket" +LinksDesc: "View some important links" +PingDesc: "Get the bot's latency" +HelpDesc: "Get a list of all the commands" +RemoveUserDesc: "Remove a user from a support ticket" +AddUserDesc: "Add a user to a support ticket" +SuggestionDesc: "Create a server suggestion" +BotSayDesc: "Say something with the bot" + +# Error / Warining Messages + +IncorrectPerms: ":x: **Err!** You do not have the correct permissions to use this command." +InvalidChannel: ":x: **Err!** Channel not found. Please create it!" +UserNotFound: ":x: **Err!** This user doesn't exist, Are they in this server?" +NoValidTicket: ":warning: You cannot execute this command here. This command is used when closing a ticket." +TicketExists: ":warning: This ticket cannot be opened, It already exists!" \ No newline at end of file From 28699f0ff0e703289eb12198b59be221e9e2367b Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Tue, 14 Jul 2020 19:42:46 +0100 Subject: [PATCH 19/33] Updated --- .DS_Store | Bin 0 -> 6148 bytes commands/BotSay.js | 37 +++++++++++++++++++++++++++++++++++ commands/addUser.js | 26 +++++++++++++----------- commands/announce.js | 9 ++++++--- commands/close.js | 5 +++-- commands/help.js | 38 ++++++++++++++++++++++-------------- commands/links.js | 1 + commands/newticket.js | 3 ++- commands/ping.js | 1 + commands/removeUser.js | 25 ++++++++++++++---------- commands/suggest.js | 5 +++-- package-lock.json | 6 +++--- storage/SupportTickets.json | 2 +- storage/TicketID.json | 2 +- supportbot-config.yml | 26 +++++++++++++++++++++++- 15 files changed, 136 insertions(+), 50 deletions(-) create mode 100644 .DS_Store create mode 100644 commands/BotSay.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..dfebe3ab0ef5582227f5aa8d6db99a41e5464fb9 GIT binary patch literal 6148 zcmeHK&2G~`5T0$*#tDBx0<}jUK;jUpRH5{MkV2XqA^}1e!2wWf$7yPC?I>{?N(jn@ zhkyq_;!$`49)t&gZ*~`CJCq}e&`z}bt=BWNyWfm=vqU7CV}F~dLPQn{W1)=d55n)c zEXa!Pxd;@}M?|Ae7} zt2YRPQBtdY6DzBQwe_N9m96rH@=NC^o;Zn{j7Lp(_?({}xyg~I+fU*+{M~lFr$KMB zU%9duM~NFmy`eM?{2o+ZJPRT}o;2feDDl2zKTY)+^3`cBoZ@6={hd%C+@ ztJ=5fw`a4GwQ+s>Zs*|m^zHQB?EOb92qLh7O1Y%*7kok^L&%9UjKVnTqn~XoP|AVm z(Hq*LR||xFhfX?xMY>NN+M_l-B!}ABP{?q9PKEn24G?G!pG$p=aTDQF;gn->%49vr zV5U8s&v`h@jsu&vE74=j@gCCW0dNZm=jTS^m8C6;G(y6}NHaOttTwMqTuZI&DzwL# z+dx_*xZzw{J4*#}PC(%%7YQunGAj`n2daUsI-#+{PpEWX1h5^ICf5m_( zw47EGOVVfS!s7U>wNVaGSXghaP@169$FXeiQM`#F1@CNb02> SupportTeam.name === supportbot.Staff) + let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) + + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\``) + .setColor(supportbot.WarningColour) + + if (!message.member.roles.cache.has(SupportStaff.id )) + return message.channel.send({ embed: NoPerms }); + + const BotSpeaks = agrs.join(" "); + + const Speaking = new Discord.MessageEmbed() + .setDescription(args.join) + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: Speaking }) + + } + +}; \ No newline at end of file diff --git a/commands/addUser.js b/commands/addUser.js index d5f249c..6d32025 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -9,22 +9,26 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.AddUser, + description: supportbot.AddUserDesc, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.AddUser}!`); - let SupportStaff = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff); + let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) + let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) - const NoPerms = new Discord.MessageEmbed() - .setTitle("Invalid Permissions!") - .setDescription(`:warning: **Err!** You do not have the correct permissions to use this command.\n\nRole Required: \`${supportbot.SupportStaff}\``) - .setColor(supportbot.WarningColour) - message.channel.send({ embed: NoPerms }); + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\``) + .setColor(supportbot.WarningColour) + + if (!message.member.roles.cache.has(SupportStaff.id)) + return message.channel.send({ embed: NoPerms }); if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) .setColor(supportbot.WarningColour); message.channel.send({ embed: Exists }); @@ -34,8 +38,8 @@ module.exports = { let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); const UserNotExist = new Discord.MessageEmbed() .setTitle("User Not Found!") - .setDescription(`:x: **Error!** This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.AddUser} \``) - .setColor(supportbot.ErrorColor) + .setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${supportbot.AddUser} \``) + .setColor(supportbot.ErrorColour) if (!rUser) return message.channel.send({ embed: UserNotExist }); @@ -48,7 +52,7 @@ module.exports = { const Complete = new Discord.MessageEmbed() .setTitle("User Added!") - .setDescription(`👍 ${rUser} has been added to this ticket`) + .setDescription(supportbot.AddedUser.replace(/%user%/g, rUser.id)) .setTimestamp() .setColor(supportbot.EmbedColour) message.channel.send({ embed: Complete }); diff --git a/commands/announce.js b/commands/announce.js index 3d57469..50205ce 100644 --- a/commands/announce.js +++ b/commands/announce.js @@ -10,6 +10,7 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.AnnounceCommand, + description: supportbot.AnnounceDesc, execute(message, args) { @@ -17,7 +18,7 @@ module.exports = { const errornochannel = new Discord.MessageEmbed() .setTitle("Invalid Channel") - .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}`) + .setDescription(`${supportbot.InvalidChannel}\n\nChannel Required: \`${supportbot.AnnouncementChannel}`) .setColor(supportbot.ErrorColour); if(!locateChannel) return message.channel.send({ embed: errornochannel }); @@ -26,9 +27,11 @@ module.exports = { const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(`:warning: **Err!** You do not have the correct permissions to use this command.\n\nRole Required: \`${supportbot.serverAdmins}\``) + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${serverAdmins.name}\``) .setColor(supportbot.WarningColour) - message.channel.send({ embed: NoPerms }); + + if (!message.member.roles.cache.has(serverAdmins.id)) + return message.channel.send({ embed: NoPerms }); const embed = new Discord.MessageEmbed() diff --git a/commands/close.js b/commands/close.js index 5fa9c2f..d45fae6 100644 --- a/commands/close.js +++ b/commands/close.js @@ -10,14 +10,15 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.CloseTicket, + description: supportbot.CloseTicketDesc, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.CloseTicket}!`); if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) .setColor(supportbot.WarningColour); message.channel.send({ embed: Exists }); diff --git a/commands/help.js b/commands/help.js index 7cac1a5..b833464 100644 --- a/commands/help.js +++ b/commands/help.js @@ -9,26 +9,24 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.HelpCommand, + description: supportbot.HelpDesc, 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`; + generalCommands += `**${supportbot.Prefix}${supportbot.HelpCommand}** ${supportbot.HelpDesc}\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.LinksCommand}** ${supportbot.LinkDesc}\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.SuggestCommand}** ${supportbot.SuggestionDesc}\n`; + generalCommands += `**${supportbot.Prefix}${supportbot.PingCommand}** ${supportbot.PingDesc}\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` + supportCommands += `**${supportbot.Prefix}${supportbot.NewTicket} [reason]** ${supportbot.NewTicketDesc}\n` + supportCommands += `**${supportbot.Prefix}${supportbot.CloseTicket} [reason]** ${supportbot.CloseTicketDesc}\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` + staffCommands += `**${supportbot.Prefix}${supportbot.AddUser} ** ${supportbot.AddUserDesc}\n` + staffCommands += `**${supportbot.Prefix}${supportbot.RemoveUser} ** ${supportbot.RemoveUserDesc}\n` + staffCommands += `**${supportbot.Prefix}${supportbot.BotSayCommand}** ${supportbot.BotSayDesc}\n` + staffCommands += `**${supportbot.Prefix}${supportbot.AnnounceCommand}** ${supportbot.AnnounceDesc}\n` const HelpCommandEmbed = new Discord.MessageEmbed() .setTitle(supportbot.Bot_Name) @@ -37,13 +35,23 @@ module.exports = { .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 }, ) .setColor(supportbot.EmbedColour) .setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL()); + if (message.member.roles.cache.some(role => role.name === supportbot.Staff, supportbot.Admin)) { + HelpCommandEmbed.addFields( + { name: '🔑 Staff Commands', value: `${staffCommands}\n`, inline: false }, + ) + } + + if (message.member.roles.cache.some(role => role.name === supportbot.Staff)) { + HelpCommandEmbed.addFields( + { name: '🔑 Staff Commands', value: `${staffCommands}\n`, inline: false }, + ) + } + message.channel.send({ embed: HelpCommandEmbed }); } }; \ No newline at end of file diff --git a/commands/links.js b/commands/links.js index f17a9c9..4282cad 100644 --- a/commands/links.js +++ b/commands/links.js @@ -10,6 +10,7 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.LinksCommand, + description: supportbot.LinksDesc, execute(message, args) { diff --git a/commands/newticket.js b/commands/newticket.js index 3995ba3..7d8514f 100644 --- a/commands/newticket.js +++ b/commands/newticket.js @@ -11,6 +11,7 @@ const reacted = []; module.exports = { name: supportbot.NewTicket, + description: supportbot.NewTicketDesc, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.NewTicket}!`); @@ -24,7 +25,7 @@ module.exports = { // Ticket Exists const TicketExists = new Discord.MessageEmbed() .setTitle("Ticket Exists!") - .setDescription(":no_entry_sign: This ticket cannot be opened, It already exists!") + .setDescription(`${supportbot.TicketExists}`) .setColor(supportbot.WarningColour) if (message.guild.channels.cache.find(SupportTicket => SupportTicket.name === `${supportbot.TicketChannel}-${ticketNumberID}`)) diff --git a/commands/ping.js b/commands/ping.js index 5a6548e..e69206c 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -9,6 +9,7 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.PingCommand, + description: supportbot.PingDesc, execute(message, args) { let ping = Date.now() - message.createdTimestamp + " ms"; diff --git a/commands/removeUser.js b/commands/removeUser.js index 7fee71b..47b02ca 100644 --- a/commands/removeUser.js +++ b/commands/removeUser.js @@ -9,21 +9,26 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.RemoveUser, + description: supportbot.RemoveUserDesc, execute(message, args) { console.log(`\u001b[32m`, `[${supportbot.Bot_Name}]:`, `\u001b[32m`, `${message.author.tag} has executed ${supportbot.Prefix}${supportbot.RemoveUser}!`); - let staffGroup = message.guild.roles.cache.find(staffRole => staffRole.name === supportbot.Staff); - const NoPerms = new Discord.MessageEmbed() - .setTitle("Invalid Permissions!") - .setDescription(":warning: **Err!** You do not have the correct permissions to use this command.") - .setColor(supportbot.WarningColour) - message.channel.send({ embed: NoPerms }); + let SupportStaff = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) + let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) + + const NoPerms = new Discord.MessageEmbed() + .setTitle("Invalid Permissions!") + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\``) + .setColor(supportbot.WarningColour) + + if (!message.member.roles.cache.has(SupportStaff.id)) + return message.channel.send({ embed: NoPerms }); if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() - .setTitle("Incorrect Channel") - .setDescription(`:warning: You cannot execute this command here. This command is used when closing a ticket.`) + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) .setColor(supportbot.WarningColour); message.channel.send({ embed: Exists }); @@ -33,7 +38,7 @@ module.exports = { let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); const UserNotExist = new Discord.MessageEmbed() .setTitle("User Not Found!") - .setDescription(`:x: **Error!** This user doesn't exist, Are they in this server?\n\nTry Again:\`${supportbot.Prefix}${supportbot.RemoveUser} \``) + .setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${supportbot.RemoveUser} \``) .setColor(supportbot.ErrorColor) if (!rUser) return message.channel.send({ embed: UserNotExist }); @@ -47,7 +52,7 @@ module.exports = { const Complete = new Discord.MessageEmbed() .setTitle("User Removed!") - .setDescription(`👍 ${rUser} has been removed from this ticket`) + .setDescription(supportbot.RemovedUser.replace(/%user%/g, rUser.id)) .setTimestamp() .setColor(supportbot.EmbedColour) message.channel.send({ embed: Complete }); diff --git a/commands/suggest.js b/commands/suggest.js index 64aadb0..7ffd398 100644 --- a/commands/suggest.js +++ b/commands/suggest.js @@ -9,13 +9,14 @@ const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')) module.exports = { name: supportbot.SuggestCommand, + description: supportbot.SuggestionDesc, 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\``) + .setTitle("Invalid Channel") + .setDescription(`${supportbot.InvalidChannel}\n\nChannel Required: \`${supportbot.SuggestionChannel}\``) .setColor(supportbot.ErrorColour); if(!locateChannel) return message.channel.send({ embed: errornochannel }); diff --git a/package-lock.json b/package-lock.json index 7540c76..76dde51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -126,9 +126,9 @@ "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, "ws": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", - "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==" + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" } } } diff --git a/storage/SupportTickets.json b/storage/SupportTickets.json index 0bc4123..7635a24 100644 --- a/storage/SupportTickets.json +++ b/storage/SupportTickets.json @@ -1,4 +1,4 @@ { - "ticket": "ticket-0058", + "ticket": "ticket-0061", "id":419821884431925260 } \ No newline at end of file diff --git a/storage/TicketID.json b/storage/TicketID.json index 9f38e34..0ece568 100644 --- a/storage/TicketID.json +++ b/storage/TicketID.json @@ -1,5 +1,5 @@ { "716992597377286145": { - "id": 59 + "id": 62 } } \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml index e1f7c46..e07dccd 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -56,6 +56,9 @@ NoTicketSubject: "No Reason Provided!" TicketCreatedAlert: ":ticket: Your support ticket has been created: <#%ticketid%>" TranscriptTitle: "Ticket Transcript" +AddedUser: "👍 <@%user%> has been added to this ticket" +RemovedUser: "👍 <@%user%> has been removed from this ticket" + ClosingTicket: ":warning: You have requested to close your support ticket." ClosingConfirmation_Word: "confirm" CloseConfirmation: "true" @@ -155,8 +158,29 @@ RenameTicket: "rename" # Staff Command Configuration -SayCommand: "say" +BotSay: "say" # Admin Command Configuration AnnounceCommand: "announce" + +# Commmand Descriptions + +NewTicketDesc: "Create a new support ticket" +AnnounceDesc: "Create a server announcement" +CloseTicketDesc: "Close your support ticket" +LinksDesc: "View some important links" +PingDesc: "Get the bot's latency" +HelpDesc: "Get a list of all the commands" +RemoveUserDesc: "Remove a user from a support ticket" +AddUserDesc: "Add a user to a support ticket" +SuggestionDesc: "Create a server suggestion" +BotSayDesc: "Say something with the bot" + +# Error / Warining Messages + +IncorrectPerms: ":x: **Err!** You do not have the correct permissions to use this command." +InvalidChannel: ":x: **Err!** Channel not found. Please create it!" +UserNotFound: ":x: **Err!** This user doesn't exist, Are they in this server?" +NoValidTicket: ":warning: You cannot execute this command here. This command is used when closing a ticket." +TicketExists: ":warning: This ticket cannot be opened, It already exists!" \ No newline at end of file From 5c98376a8c51ce9f508d2bc12a1c8837e5f7338c Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Wed, 15 Jul 2020 02:16:15 +0100 Subject: [PATCH 20/33] RolePerms Update --- commands/BotSay.js | 21 +++++++----- commands/addUser.js | 68 ++++++++++++++++++++----------------- commands/announce.js | 6 ++-- commands/help.js | 8 +---- commands/helptest.js | 33 ++++++++++++++++++ commands/removeUser.js | 68 +++++++++++++++++++------------------ storage/SupportTickets.json | 2 +- storage/TicketID.json | 2 +- 8 files changed, 123 insertions(+), 85 deletions(-) create mode 100644 commands/helptest.js diff --git a/commands/BotSay.js b/commands/BotSay.js index 82f80bb..5a4b9dd 100644 --- a/commands/BotSay.js +++ b/commands/BotSay.js @@ -19,18 +19,23 @@ module.exports = { const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\``) + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id )) + if (!message.member.roles.cache.has(SupportStaff.id || Admins.id)) { + + const BotSpeaks = agrs.join(" "); + + const Speaking = new Discord.MessageEmbed() + .setDescription(args.join) + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: Speaking }) + + } else { + return message.channel.send({ embed: NoPerms }); - const BotSpeaks = agrs.join(" "); - - const Speaking = new Discord.MessageEmbed() - .setDescription(args.join) - .setColor(supportbot.EmbedColour) - message.channel.send({ embed: Speaking }) + } } diff --git a/commands/addUser.js b/commands/addUser.js index 6d32025..9a345de 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -19,42 +19,46 @@ module.exports = { const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\``) + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id)) + if (!message.member.roles.cache.has(SupportStaff.id || Admins.id)) { + if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { + const Exists = new Discord.MessageEmbed() + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) + .setColor(supportbot.WarningColour); + message.channel.send({ embed: Exists }); + + return; + } + + let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); + const UserNotExist = new Discord.MessageEmbed() + .setTitle("User Not Found!") + .setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${supportbot.AddUser} \``) + .setColor(supportbot.ErrorColour) + + if (!rUser) return message.channel.send({ embed: UserNotExist }); + + message.channel.updateOverwrite(rUser, { + VIEW_CHANNEL: true, + CREATE_INVITE: false, + SEND_MESSAGES: true, + READ_MESSAGES: true + }); + + const Complete = new Discord.MessageEmbed() + .setTitle("User Added!") + .setDescription(supportbot.AddedUser.replace(/%user%/g, rUser.id)) + .setTimestamp() + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: Complete }); + } else { + return message.channel.send({ embed: NoPerms }); - if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { - const Exists = new Discord.MessageEmbed() - .setTitle("No Ticket Found!") - .setDescription(`${supportbot.NoValidTicket}`) - .setColor(supportbot.WarningColour); - message.channel.send({ embed: Exists }); + } - return; - } - - let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); - const UserNotExist = new Discord.MessageEmbed() - .setTitle("User Not Found!") - .setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${supportbot.AddUser} \``) - .setColor(supportbot.ErrorColour) - - if (!rUser) return message.channel.send({ embed: UserNotExist }); - - message.channel.updateOverwrite(rUser, { - VIEW_CHANNEL: true, - CREATE_INVITE: false, - SEND_MESSAGES: true, - READ_MESSAGES: true - }); - - const Complete = new Discord.MessageEmbed() - .setTitle("User Added!") - .setDescription(supportbot.AddedUser.replace(/%user%/g, rUser.id)) - .setTimestamp() - .setColor(supportbot.EmbedColour) - message.channel.send({ embed: Complete }); } }; diff --git a/commands/announce.js b/commands/announce.js index 50205ce..fff1a6e 100644 --- a/commands/announce.js +++ b/commands/announce.js @@ -23,14 +23,14 @@ module.exports = { if(!locateChannel) return message.channel.send({ embed: errornochannel }); - let serverAdmins = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Admin); + let Admins = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Admin); const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${serverAdmins.name}\``) + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${Admins.name}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(serverAdmins.id)) + if (!message.member.roles.cache.has(Admins.id)) return message.channel.send({ embed: NoPerms }); diff --git a/commands/help.js b/commands/help.js index b833464..e7568fa 100644 --- a/commands/help.js +++ b/commands/help.js @@ -40,13 +40,7 @@ module.exports = { .setColor(supportbot.EmbedColour) .setFooter(supportbot.EmbedFooter, message.author.displayAvatarURL()); - if (message.member.roles.cache.some(role => role.name === supportbot.Staff, supportbot.Admin)) { - HelpCommandEmbed.addFields( - { name: '🔑 Staff Commands', value: `${staffCommands}\n`, inline: false }, - ) - } - - if (message.member.roles.cache.some(role => role.name === supportbot.Staff)) { + if (message.member.roles.cache.some(role => role.name === supportbot.Staff || supportbot.Admin)) { HelpCommandEmbed.addFields( { name: '🔑 Staff Commands', value: `${staffCommands}\n`, inline: false }, ) diff --git a/commands/helptest.js b/commands/helptest.js new file mode 100644 index 0000000..aa46695 --- /dev/null +++ b/commands/helptest.js @@ -0,0 +1,33 @@ +// SupportBot 6.0, Created by Emerald Services +// Links Command + +const Discord = require("discord.js"); +const fs = require("fs"); + +const yaml = require('js-yaml'); +const { execute } = require("./help"); +const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); + +module.exports = { + name: supportbot.LinksCommand, + description: supportbot.LinksDesc, + + execute(message, args) { + + const LinksEmbed = new Discord.MessageEmbed() + .setColor(supportbot.EmbedColour) + + let botLinks = supportbot.HELP; + + let links = ''; + + for ( let name in botLinks ) { + links += `[${name}](${botLinks[ name ]})\n`; + }; + + LinksEmbed.addField(supportbot.HelpTitle, links) + + message.channel.send({ embed: LinksEmbed }); + + } +}; \ No newline at end of file diff --git a/commands/removeUser.js b/commands/removeUser.js index 47b02ca..4d260d9 100644 --- a/commands/removeUser.js +++ b/commands/removeUser.js @@ -19,42 +19,44 @@ module.exports = { const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\``) + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id)) + if (!message.member.roles.cache.has(SupportStaff.id || Admins.id)) { + if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { + const Exists = new Discord.MessageEmbed() + .setTitle("No Ticket Found!") + .setDescription(`${supportbot.NoValidTicket}`) + .setColor(supportbot.WarningColour); + message.channel.send({ embed: Exists }); + + return; + } + + let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); + const UserNotExist = new Discord.MessageEmbed() + .setTitle("User Not Found!") + .setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${supportbot.RemoveUser} \``) + .setColor(supportbot.ErrorColour) + + if (!rUser) return message.channel.send({ embed: UserNotExist }); + + message.channel.updateOverwrite(rUser, { + VIEW_CHANNEL: false, + CREATE_INVITE: false, + SEND_MESSAGES: false, + READ_MESSAGES: false + }); + + const Complete = new Discord.MessageEmbed() + .setTitle("User Removed!") + .setDescription(supportbot.RemovedUser.replace(/%user%/g, rUser.id)) + .setTimestamp() + .setColor(supportbot.EmbedColour) + message.channel.send({ embed: Complete }); + } else { return message.channel.send({ embed: NoPerms }); + } - if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { - const Exists = new Discord.MessageEmbed() - .setTitle("No Ticket Found!") - .setDescription(`${supportbot.NoValidTicket}`) - .setColor(supportbot.WarningColour); - message.channel.send({ embed: Exists }); - - return; - } - - let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[0])); - const UserNotExist = new Discord.MessageEmbed() - .setTitle("User Not Found!") - .setDescription(`${supportbot.UserNotFound}\n\nTry Again:\`${supportbot.Prefix}${supportbot.RemoveUser} \``) - .setColor(supportbot.ErrorColor) - - if (!rUser) return message.channel.send({ embed: UserNotExist }); - - message.channel.updateOverwrite(rUser, { - VIEW_CHANNEL: false, - CREATE_INVITE: false, - SEND_MESSAGES: false, - READ_MESSAGES: false - }); - - const Complete = new Discord.MessageEmbed() - .setTitle("User Removed!") - .setDescription(supportbot.RemovedUser.replace(/%user%/g, rUser.id)) - .setTimestamp() - .setColor(supportbot.EmbedColour) - message.channel.send({ embed: Complete }); } }; diff --git a/storage/SupportTickets.json b/storage/SupportTickets.json index 7635a24..63b9e40 100644 --- a/storage/SupportTickets.json +++ b/storage/SupportTickets.json @@ -1,4 +1,4 @@ { - "ticket": "ticket-0061", + "ticket": "ticket-0062", "id":419821884431925260 } \ No newline at end of file diff --git a/storage/TicketID.json b/storage/TicketID.json index 0ece568..6a8227a 100644 --- a/storage/TicketID.json +++ b/storage/TicketID.json @@ -1,5 +1,5 @@ { "716992597377286145": { - "id": 62 + "id": 63 } } \ No newline at end of file From cc5a6b7317d0794ba0d3e7ab86c65361526b7274 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Wed, 15 Jul 2020 02:20:05 +0100 Subject: [PATCH 21/33] Update BotSay.js --- commands/BotSay.js | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/commands/BotSay.js b/commands/BotSay.js index 5a4b9dd..c90df2c 100644 --- a/commands/BotSay.js +++ b/commands/BotSay.js @@ -1,5 +1,5 @@ // SupportBot 6.0, Created by Emerald Services -// Bot Say Command +// Say Command const Discord = require("discord.js"); const fs = require("fs"); @@ -14,29 +14,37 @@ module.exports = { execute(message, args) { - 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 SupportStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Staff); const NoPerms = new Discord.MessageEmbed() .setTitle("Invalid Permissions!") - .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) + .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${SupportStaff.name}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id || Admins.id)) { - - const BotSpeaks = agrs.join(" "); - - const Speaking = new Discord.MessageEmbed() - .setDescription(args.join) - .setColor(supportbot.EmbedColour) - message.channel.send({ embed: Speaking }) - - } else { - + if (!message.member.roles.cache.has(SupportStaff.id)) return message.channel.send({ embed: NoPerms }); - } - } + const embed = new Discord.MessageEmbed() + .setDescription(`> **What would you like me to say!**`) + .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() + .setDescription(announcement) + .setColor(supportbot.EmbedColour) + + message.channel.send({ embed: AnnouncementEmbed }) + }) + + } }; \ No newline at end of file From c752a07ad01bf4a4dd94b99deba3fed07fd00893 Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 11:37:17 -0400 Subject: [PATCH 22/33] fix adduser --- commands/addUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/addUser.js b/commands/addUser.js index 9a345de..76e85dd 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id || Admins.id)) { + if (!message.member.roles.cache.has(SupportStaff.id) || !message.member.roles.cache.has(Admins.id)) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From 0a230cfab94a01294fca8f1b1a3c72829e5b614b Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 11:37:58 -0400 Subject: [PATCH 23/33] fix remove --- commands/removeUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/removeUser.js b/commands/removeUser.js index 4d260d9..0dd361b 100644 --- a/commands/removeUser.js +++ b/commands/removeUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id || Admins.id)) { + if (!message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From afdb16da07cacf2249e57816b9ac7c7ba73daa49 Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 11:44:01 -0400 Subject: [PATCH 24/33] Update addUser.js --- commands/addUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/addUser.js b/commands/addUser.js index 76e85dd..094ddfc 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id) || !message.member.roles.cache.has(Admins.id)) { + if (!(message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id))) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From 95e92970c9da34a58ac3f43b665de7fd1373e4dd Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 11:44:17 -0400 Subject: [PATCH 25/33] Update removeUser.js --- commands/removeUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/removeUser.js b/commands/removeUser.js index 0dd361b..b68ffd7 100644 --- a/commands/removeUser.js +++ b/commands/removeUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { + if (!(message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id))) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From 48b542293ff5789edb335148d721aa4596e6b616 Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 11:56:52 -0400 Subject: [PATCH 26/33] Update addUser.js --- commands/addUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/addUser.js b/commands/addUser.js index 094ddfc..70a242c 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!(message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id))) { + if ((message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id))) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From c64f249fd0882259b6000bb104c87112490eb655 Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 11:57:14 -0400 Subject: [PATCH 27/33] Update removeUser.js --- commands/removeUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/removeUser.js b/commands/removeUser.js index b68ffd7..8c3d797 100644 --- a/commands/removeUser.js +++ b/commands/removeUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!(message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id))) { + if ((message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) === false) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From a4c0eeb9b3edbb847f469b61330733997789452b Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 11:57:32 -0400 Subject: [PATCH 28/33] Update addUser.js --- commands/addUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/addUser.js b/commands/addUser.js index 70a242c..5b1bc99 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if ((message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id))) { + if ((message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) === false) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From fb3f87c68576d2cf7d323fb12ad503a67b0cd676 Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 12:05:24 -0400 Subject: [PATCH 29/33] Update addUser.js --- commands/addUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/addUser.js b/commands/addUser.js index 5b1bc99..daf1aae 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if ((message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) === false) { + if (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From 36fc9aae6c8f6eef7c8b35ace3cf730d93e21352 Mon Sep 17 00:00:00 2001 From: doge Date: Wed, 15 Jul 2020 12:05:39 -0400 Subject: [PATCH 30/33] Update removeUser.js --- commands/removeUser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/removeUser.js b/commands/removeUser.js index 8c3d797..61be952 100644 --- a/commands/removeUser.js +++ b/commands/removeUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if ((message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) === false) { + if (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") From 4f05ad65467fc2e1707a0fac4b3a6d5b69877aae Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Wed, 15 Jul 2020 18:42:07 +0100 Subject: [PATCH 31/33] SupportBot 6.0 BETA 1 --- addons/addon-example.js | 19 ++++++++++++++++++ addons/settings/exampleaddon.yml | 9 +++++++++ commands/addUser.js | 4 ++-- commands/helptest.js | 33 -------------------------------- commands/removeUser.js | 4 ++-- index.js | 2 +- storage/SupportTickets.json | 4 ++-- storage/TicketID.json | 2 +- supportbot-config.yml | 14 +++++++------- 9 files changed, 43 insertions(+), 48 deletions(-) create mode 100644 addons/addon-example.js create mode 100644 addons/settings/exampleaddon.yml delete mode 100644 commands/helptest.js diff --git a/addons/addon-example.js b/addons/addon-example.js new file mode 100644 index 0000000..76ec67b --- /dev/null +++ b/addons/addon-example.js @@ -0,0 +1,19 @@ +// SupportBot 6.0, Created by Emerald Services +// Help Command + +const Discord = require("discord.js"); +const fs = require("fs"); + +const yaml = require('js-yaml'); + +// location for the addons configuration, to keep it simple we generate a settings folder within the addons directory. +const example = yaml.load(fs.readFileSync('./addons/settings/exampleaddon.yml', 'utf8')); + +module.exports = { + name: example.ExampleAddonCommand, + description: example.ExampleAddonDesc, + + execute(message, args) { + message.channel.send(example.ExampleAddonMessage) + } +}; \ No newline at end of file diff --git a/addons/settings/exampleaddon.yml b/addons/settings/exampleaddon.yml new file mode 100644 index 0000000..91876a0 --- /dev/null +++ b/addons/settings/exampleaddon.yml @@ -0,0 +1,9 @@ +# +# SupportBot 6.0 +# Example Addon +# + +ExampleAddonCommand: "exampleaddon" +ExampleAddonDesc: "This is the default/example addon for SupportBot." + +ExampleAddonMessage: "> :white_check_mark: This is the **default** addon for SupportBot. You can download addons from our website, https://emeraldservices.xyz/" \ No newline at end of file diff --git a/commands/addUser.js b/commands/addUser.js index 9a345de..d30ca34 100644 --- a/commands/addUser.js +++ b/commands/addUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id || Admins.id)) { + if (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") @@ -61,4 +61,4 @@ module.exports = { } } -}; +}; \ No newline at end of file diff --git a/commands/helptest.js b/commands/helptest.js deleted file mode 100644 index aa46695..0000000 --- a/commands/helptest.js +++ /dev/null @@ -1,33 +0,0 @@ -// SupportBot 6.0, Created by Emerald Services -// Links Command - -const Discord = require("discord.js"); -const fs = require("fs"); - -const yaml = require('js-yaml'); -const { execute } = require("./help"); -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -module.exports = { - name: supportbot.LinksCommand, - description: supportbot.LinksDesc, - - execute(message, args) { - - const LinksEmbed = new Discord.MessageEmbed() - .setColor(supportbot.EmbedColour) - - let botLinks = supportbot.HELP; - - let links = ''; - - for ( let name in botLinks ) { - links += `[${name}](${botLinks[ name ]})\n`; - }; - - LinksEmbed.addField(supportbot.HelpTitle, links) - - message.channel.send({ embed: LinksEmbed }); - - } -}; \ No newline at end of file diff --git a/commands/removeUser.js b/commands/removeUser.js index 4d260d9..34cb52f 100644 --- a/commands/removeUser.js +++ b/commands/removeUser.js @@ -22,7 +22,7 @@ module.exports = { .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${supportbot.Staff}\` or \`${supportbot.Admin}\``) .setColor(supportbot.WarningColour) - if (!message.member.roles.cache.has(SupportStaff.id || Admins.id)) { + if (message.member.roles.cache.has(SupportStaff.id) || message.member.roles.cache.has(Admins.id)) { if (!message.channel.name.startsWith( `${supportbot.TicketChannel}-` )) { const Exists = new Discord.MessageEmbed() .setTitle("No Ticket Found!") @@ -59,4 +59,4 @@ module.exports = { } } -}; +}; \ No newline at end of file diff --git a/index.js b/index.js index 674321e..eb0483f 100644 --- a/index.js +++ b/index.js @@ -78,7 +78,7 @@ fs.readdir("./addons/", (err, files) => { } jsfiles.forEach((f, i) => { - let props = require(`./commands/${f}`); + let props = require(`./addons/${f}`); console.info(`\u001b[37m`, `[${supportbot.Bot_Name}]:`, `\u001b[31m`, `#${i + 1} Command Loaded: ${props.name.toProperCase()}`); bot.commands.set(props.name, props); }); diff --git a/storage/SupportTickets.json b/storage/SupportTickets.json index 63b9e40..72a7bfd 100644 --- a/storage/SupportTickets.json +++ b/storage/SupportTickets.json @@ -1,4 +1,4 @@ { - "ticket": "ticket-0062", - "id":419821884431925260 + "ticket": "ticket-0064", + "id":207937608779694080 } \ No newline at end of file diff --git a/storage/TicketID.json b/storage/TicketID.json index 6a8227a..052c513 100644 --- a/storage/TicketID.json +++ b/storage/TicketID.json @@ -1,5 +1,5 @@ { "716992597377286145": { - "id": 63 + "id": 65 } } \ No newline at end of file diff --git a/supportbot-config.yml b/supportbot-config.yml index 239e0c9..91d324a 100644 --- a/supportbot-config.yml +++ b/supportbot-config.yml @@ -11,15 +11,13 @@ # General Bot Configuration -Token: "NjcyMTU5MjQyNjg5NzA4MDUz.XwnBpg.6eCCVRv4m-aVPJuppHWNxpxpRs0" -Prefix: "!!" -Bot_Name: "SupportBot DEV" +Token: "BOT_TOKEN_HERE" +Prefix: "-" +Bot_Name: "SupportBot" -BotActivity: "SB-6.0 dev-0.1" +BotActivity: "!help ~ SupportBot 6.0" ActivityType: "PLAYING" - -ShowErrorCodes: "true" -# This feature will show supportbot error codes such as "SB-01" +# Activity status can either be PLAYING, WATCHING or LISTENING. # Embed Configuration @@ -98,9 +96,11 @@ SystemMessage_Icon: "USER" Welcome_Title: "User Joined!" WelcomeMessage: "Hello %member%, Welcome to %guildname%!" +# %member% define the user who joined and %guildnamne% defines the server name. Leave_Title: "User Left!" LeaveMessage: "Goodbye %member%, Thank you for visting %guildname%!" +# %member% define the user who left and %guildnamne% defines the server name. SystemMessage_EmbedFooter: "false" From d0a6bed7270f945e909d530db4389c6d84761bfe Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Thu, 23 Jul 2020 17:40:31 +0100 Subject: [PATCH 32/33] Delete BotSay.js --- commands/BotSay.js | 50 ---------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 commands/BotSay.js diff --git a/commands/BotSay.js b/commands/BotSay.js deleted file mode 100644 index c90df2c..0000000 --- a/commands/BotSay.js +++ /dev/null @@ -1,50 +0,0 @@ -// SupportBot 6.0, Created by Emerald Services -// Say Command - -const Discord = require("discord.js"); -const fs = require("fs"); - -const yaml = require('js-yaml'); -const { execute } = require("./help"); -const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8')); - -module.exports = { - name: supportbot.BotSay, - description: supportbot.BotSayDesc, - - execute(message, args) { - - let SupportStaff = message.guild.roles.cache.find(adminRole => adminRole.name === supportbot.Staff); - - const NoPerms = new Discord.MessageEmbed() - .setTitle("Invalid Permissions!") - .setDescription(`${supportbot.IncorrectPerms}\n\nRole Required: \`${SupportStaff.name}\``) - .setColor(supportbot.WarningColour) - - if (!message.member.roles.cache.has(SupportStaff.id)) - return message.channel.send({ embed: NoPerms }); - - - const embed = new Discord.MessageEmbed() - .setDescription(`> **What would you like me to say!**`) - .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() - .setDescription(announcement) - .setColor(supportbot.EmbedColour) - - message.channel.send({ embed: AnnouncementEmbed }) - }) - - } - -}; \ No newline at end of file From 87b9301e20d90d540fd4f05af144fe950ea3faa2 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Thu, 23 Jul 2020 20:16:32 +0100 Subject: [PATCH 33/33] Update help.js --- commands/help.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/help.js b/commands/help.js index e7568fa..4a54852 100644 --- a/commands/help.js +++ b/commands/help.js @@ -25,7 +25,7 @@ module.exports = { let staffCommands = ""; staffCommands += `**${supportbot.Prefix}${supportbot.AddUser} ** ${supportbot.AddUserDesc}\n` staffCommands += `**${supportbot.Prefix}${supportbot.RemoveUser} ** ${supportbot.RemoveUserDesc}\n` - staffCommands += `**${supportbot.Prefix}${supportbot.BotSayCommand}** ${supportbot.BotSayDesc}\n` + staffCommands += `**${supportbot.Prefix}${supportbot.BotSay}** ${supportbot.BotSayDesc}\n` staffCommands += `**${supportbot.Prefix}${supportbot.AnnounceCommand}** ${supportbot.AnnounceDesc}\n` const HelpCommandEmbed = new Discord.MessageEmbed() @@ -48,4 +48,4 @@ module.exports = { message.channel.send({ embed: HelpCommandEmbed }); } -}; \ No newline at end of file +};