commit 5e5735bf255225e6ace5698e9daefc12c673f22d Author: ItzEmerald Date: Sun Jun 9 23:52:41 2019 +0100 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e1da6ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,76 @@ +# 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/commands/add.js b/commands/add.js new file mode 100644 index 0000000..cdc9d2b --- /dev/null +++ b/commands/add.js @@ -0,0 +1,60 @@ +// SupportBot +// Command: Add User + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +module.exports.run = async (bot, message, args) => { + message.delete() + +console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Add_Command}`) + +let staffGroup = message.guild.roles.find(staffRole => staffRole.name === bot.settings.support) + +const rolemissing = new Discord.RichEmbed() + .setDescription(`:x: Looks like this server doesn't have the role **${bot.settings.support}**`) + .setColor(bot.settings.colour) +if (!staffGroup) return message.reply({embed: rolemissing}); + +const donothaverole = new Discord.RichEmbed() + .setDescription(`:x: Sorry! You cannot use this command with the role **${bot.settings.support}**`) + .setColor(bot.settings.colour) +if (!message.member.roles.has(staffGroup.id)) return message.reply({embed: donothaverole}); + +const outsideticket = new Discord.RichEmbed() + .setDescription(`:x: Cannot use this command becase you are outside a ticket channel.`) + .setColor(bot.settings.colour) +if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send({embed: outsideticket}); + +let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0])); + +const cantfinduser = new Discord.RichEmbed() + .setDescription(`:x: Hmm! Does that user exist? I cannot find the user.`) + .setColor(bot.settings.colour) +if(!rUser) return message.channel.send({embed: cantfinduser}); + +const channel = message.guild.channels.find(channel => channel.name === message.channel.name); + +const cantfindchannel = new Discord.RichEmbed() + .setDescription(`:x: Hmm! Does that ticket exist? I cannot find the ticket channel.`) + .setColor(bot.settings.colour) +if(!channel) return message.channel.send({embed: cantfindchannel}); +message.delete().catch(O_o=>{}); + +message.channel.overwritePermissions(rUser, { READ_MESSAGES: true, SEND_MESSAGES: true }); + +const useradded = new Discord.RichEmbed() + .setColor(bot.settings.colour) + .setDescription(`:white_check_mark: Successfully Added ${rUser} to the ticket.`) + .setTimestamp(); + +message.channel.send({embed: useradded}); +console.log(`\x1b[36m`, `${message.author} has successfully added ${rUser} to ${message.channel}`) + +} + +exports.help = { + name: bot.settings.Add_Command, + } \ No newline at end of file diff --git a/commands/close.js b/commands/close.js new file mode 100644 index 0000000..3fdf545 --- /dev/null +++ b/commands/close.js @@ -0,0 +1,43 @@ +// SupportBot +// Command: Close Ticket + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = (bot, message, args) => { + message.delete(); + + const outsideticket = new Discord.RichEmbed() + .setDescription(`:x: Cannot use this command becase you are outside a ticket channel.`) + .setColor(bot.settings.colour) +if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send({embed: outsideticket}); +const close1 = new Discord.RichEmbed() + .setDescription(`Looks like you have come to the end of your support ticket\nPlease confirm that you want to close your ticket by saying ||**confirm**||`) + .setFooter("Your request will be avoided in 20 seconds") + .setColor(bot.settings.colour) +message.channel.send({embed: close1}).then(m => { + message.channel.awaitMessages(response => response.content === `confirm`, { + max: 1, + time: 10000, + errors: ['time'], + + }).then((collected) => { + message.channel.delete(); + + }).catch(() => { + m.edit('Close ticket request, timedout').then(m2 => { + m2.delete(); + }, 3000); + + }); +}); + +console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Close_Command}`) + +} + +exports.help = { + name: bot.settings.Close_Command, +} \ No newline at end of file diff --git a/commands/forceclose.js b/commands/forceclose.js new file mode 100644 index 0000000..8c23a0d --- /dev/null +++ b/commands/forceclose.js @@ -0,0 +1,36 @@ +// SupportBot +// Command: Forceclose Ticket + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = (bot, message, args) => { + message.delete(); + + let staffGroup = message.guild.roles.find(staffRole => staffRole.name === `${bot.settings.support}`) + +const rolemissing = new Discord.RichEmbed() + .setDescription(`:x: Looks like this server doesn't have the role **${bot.settings.support}**`) + .setColor(bot.settings.colour) +if (!staffGroup) return message.reply({embed: rolemissing}); + +const donothaverole = new Discord.RichEmbed() + .setDescription(`:x: Sorry! You cannot use this command with the role **${bot.settings.support}**`) + .setColor(bot.settings.colour) +if (!message.member.roles.has(staffGroup.id)) return message.reply({embed: donothaverole}); + +const outsideticket = new Discord.RichEmbed() + .setDescription(`:x: Cannot use this command becase you are outside a ticket channel.`) + .setColor(bot.settings.colour) +if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send({embed: outsideticket}); +message.channel.delete(); + +console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Forceclose_Command}`) + +} + +exports.help = { + name: bot.settings.Forceclose_Command, +} \ No newline at end of file diff --git a/commands/help.js b/commands/help.js new file mode 100644 index 0000000..137705f --- /dev/null +++ b/commands/help.js @@ -0,0 +1,46 @@ +// SupportBot +// Command: Help + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = (bot, message, args) => { + message.delete(); + + let userCommands = ""; + userCommands += `**${bot.settings.prefix}${bot.settings.Link_Command}**: Get some important links!\n`; + userCommands += `**${bot.settings.prefix}${bot.settings.Ping_Command}**: Check the bots ping. Pong!\n`; + userCommands += `**${bot.settings.prefix}${bot.settings.Ticket_Command} **: Create a support ticket\n`; + userCommands += `**${bot.settings.prefix}${bot.settings.Close_Command}**: Close your support ticket\n`; + userCommands += `**${bot.settings.prefix}${bot.settings.Suggest_Command} **: Create a server suggestion\n`; + + let supportCommands = ""; + supportCommands += `**${bot.settings.prefix}${bot.settings.Add_Command} **: Adds a user to a ticket\n`; + supportCommands += `**${bot.settings.prefix}${bot.settings.Remove_Command} **: Removes a user from a ticket\n`; + supportCommands += `**${bot.settings.prefix}${bot.settings.Forceclose_Command}**: Forceclose a support ticket\n`; + supportCommands += `**${bot.settings.prefix}${bot.settings.Rename_Command}**: Rename a support ticket\n`; + + let staffCommands = ""; + staffCommands += `**${bot.settings.prefix}${bot.settings.Say_Command} **: Create a bot announcement\n`; + staffCommands += `**${bot.settings.prefix}${bot.settings.Lockchat_Command}**: Lock the chat channel\n`; + staffCommands += `**${bot.settings.prefix}${bot.settings.UnLockchat_Command}**: UnLock the chat channel\n`; + + const embed = new Discord.RichEmbed() + .setTitle(bot.settings.botname) + .addField(":ticket: Support Commands", userCommands) + .addField(":pushpin: Support Commands", supportCommands, true) + .addField(":pushpin: Staff Commands", staffCommands, true) + .setColor(bot.settings.colour) + .setFooter(bot.settings.footer, message.author.displayAvatarURL); + + message.channel.send(embed) + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Help_Command}`) + +} + +exports.help = { + name: bot.settings.Help_Command, +} \ No newline at end of file diff --git a/commands/links.js b/commands/links.js new file mode 100644 index 0000000..ae215ab --- /dev/null +++ b/commands/links.js @@ -0,0 +1,30 @@ +// SupportBot +// Command: Help + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = (bot, message, args) => { + message.delete(); + + let BotLinks = ""; + BotLinks += `[${bot.settings.LINK_1_NAME}](${bot.settings.LINK_1})\n`; + BotLinks += `[${bot.settings.LINK_2_NAME}](${bot.settings.LINK_2})\n`; + BotLinks += `[${bot.settings.LINK_3_NAME}](${bot.settings.LINK_3})\n`; + + const links = new Discord.RichEmbed() + .setTitle(`${bot.settings.LINKS_TITLE}`) + .setDescription(BotLinks) + .setColor(bot.settings.colour) + .setFooter(bot.settings.footer) + message.channel.send(links) + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Link_Command}`) + +} + +exports.help = { + name: bot.settings.Link_Command, +} \ No newline at end of file diff --git a/commands/lockchat.js b/commands/lockchat.js new file mode 100644 index 0000000..6e787d7 --- /dev/null +++ b/commands/lockchat.js @@ -0,0 +1,38 @@ +// SupportBot +// Command: Lockchat + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = async(bot, message, args) => { + message.delete(); + + let staffGroup = message.guild.roles.find(staffRole => staffRole.name === `${bot.settings.staff}`) + let everyoneRole = message.guild.roles.find(everyone => everyone.name === `${bot.settings.everyone}`) + + const rolemissing = new Discord.RichEmbed() + .setDescription(`:x: Looks like this server doesn't have the role **${bot.settings.staff}**`) + .setColor(bot.settings.colour) + if (!staffGroup) return message.reply(rolemissing).catch(err=>{console.error(err)}) + + const donothaverole = new Discord.RichEmbed() + .setDescription(`:x: Sorry! You cannot use this command with the role **${bot.settings.staff}**`) + .setColor(bot.settings.colour) + if (!message.member.roles.has(staffGroup.id)) return message.reply(donothaverole) + + message.channel.overwritePermissions(everyoneRole, { READ_MESSAGES: false, SEND_MESSAGES: false }); + + const lockmsg = new Discord.RichEmbed() + .setDescription(":white_check_mark: **Chat Locked**") + .setColor(bot.settings.colour) + message.channel.send(lockmsg) + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Lockchat_Command}`) + +} + +exports.help = { + name: bot.settings.Lockchat_Command, +} \ No newline at end of file diff --git a/commands/ping.js b/commands/ping.js new file mode 100644 index 0000000..444ffcf --- /dev/null +++ b/commands/ping.js @@ -0,0 +1,23 @@ +// SupportBot +// Command: Ping + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = (bot, message, args) => { + message.delete(); + + const embed = new Discord.RichEmbed() + .setDescription(`:ping_pong: **Pong!** \`${bot.ping}ms\` `) + .setColor(bot.settings.colour) + message.channel.send(embed).catch(console.error); + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Ping_Command}`) + +} + +exports.help = { + name: bot.settings.Ping_Command, +} \ No newline at end of file diff --git a/commands/poll.js b/commands/poll.js new file mode 100644 index 0000000..bf1ec49 --- /dev/null +++ b/commands/poll.js @@ -0,0 +1,46 @@ +// SupportBot +// Command: Poll + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = (bot, message, args) => { + message.delete(); + + let staffGroup = message.guild.roles.find(staffRole => staffRole.name === `${bot.settings.staff}`) + + const rolemissing = new Discord.RichEmbed() + .setDescription(`:x: Looks like this server doesn't have the role **${bot.settings.staff}**`) + .setColor(bot.settings.colour) + if (!staffGroup) return message.reply(rolemissing).catch(err=>{console.error(err)}) + + const donothaverole = new Discord.RichEmbed() + .setDescription(`:x: Sorry! You cannot use this command with the role **${bot.settings.staff}**`) + .setColor(bot.settings.colour) + if (!message.member.roles.has(staffGroup.id)) return message.reply(donothaverole) + + const embed = new Discord.RichEmbed() + .setTitle(`${bot.settings.Poll_Title}`) + .setDescription(args.join(" ")) + .setTimestamp() + .setColor(bot.settings.colour) + .setFooter(bot.settings.footer, message.author.displayAvatarURL) + + let ac = message.guild.channels.find(AnnounceChannel => AnnounceChannel.name === `${bot.settings.Poll_Channel}`) + if(!ac) return message.channel.send(`:x: Error! Could not find the logs channel **${bot.settings.Poll_Channel}**`) + + ac.send(embed) + + .then(async function(msg) { + msg.react(bot.settings.Reaction_Poll_1).then(() => msg.react(bot.settings.Reaction_Poll_2)); + }); + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Poll_Command}`) + +} + +exports.help = { + name: bot.settings.Poll_Command, +} \ No newline at end of file diff --git a/commands/remove.js b/commands/remove.js new file mode 100644 index 0000000..8dd3451 --- /dev/null +++ b/commands/remove.js @@ -0,0 +1,60 @@ +// SupportBot +// Command: Remove User + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +module.exports.run = async (bot, message, args) => { + message.delete() + +console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Add_Command}`) + +let staffGroup = message.guild.roles.find(staffRole => staffRole.name === bot.settings.support) + +const rolemissing = new Discord.RichEmbed() + .setDescription(`:x: Looks like this server doesn't have the role **${bot.settings.support}**`) + .setColor(bot.settings.colour) +if (!staffGroup) return message.reply({embed: rolemissing}); + +const donothaverole = new Discord.RichEmbed() + .setDescription(`:x: Sorry! You cannot use this command with the role **${bot.settings.support}**`) + .setColor(bot.settings.colour) +if (!message.member.roles.has(staffGroup.id)) return message.reply({embed: donothaverole}); + +const outsideticket = new Discord.RichEmbed() + .setDescription(`:x: Cannot use this command becase you are outside a ticket channel.`) + .setColor(bot.settings.colour) +if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send({embed: outsideticket}); + +let rUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0])); + +const cantfinduser = new Discord.RichEmbed() + .setDescription(`:x: Hmm! Does that user exist? I cannot find the user.`) + .setColor(bot.settings.colour) +if(!rUser) return message.channel.send({embed: cantfinduser}); + +const channel = message.guild.channels.find(channel => channel.name === message.channel.name); + +const cantfindchannel = new Discord.RichEmbed() + .setDescription(`:x: Hmm! Does that ticket exist? I cannot find the ticket channel.`) + .setColor(bot.settings.colour) +if(!channel) return message.channel.send({embed: cantfindchannel}); +message.delete().catch(O_o=>{}); + +message.channel.overwritePermissions(rUser, { READ_MESSAGES: false, SEND_MESSAGES: false }); + +const useradded = new Discord.RichEmbed() + .setColor(bot.settings.colour) + .setDescription(`:white_check_mark: Successfully remove ${rUser} from the ticket.`) + .setTimestamp(); + +message.channel.send({embed: useradded}); +console.log(`\x1b[36m`, `${message.author} has successfully removed ${rUser} from ${message.channel}`) + +} + +exports.help = { + name: bot.settings.Remove_Command, + } \ No newline at end of file diff --git a/commands/rename.js b/commands/rename.js new file mode 100644 index 0000000..d7f7bc0 --- /dev/null +++ b/commands/rename.js @@ -0,0 +1,49 @@ +// SupportBot +// Command: Close Ticket + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = (bot, message, args) => { + message.delete(); + + let staffGroup = message.guild.roles.find(staffRole => staffRole.name === bot.settings.support) + + const rolemissing = new Discord.RichEmbed() + .setDescription(`:x: Looks like this server doesn't have the role **${bot.settings.support}**`) + .setColor(bot.settings.colour) + if (!staffGroup) return message.reply({embed: rolemissing}); + + const donothaverole = new Discord.RichEmbed() + .setDescription(`:x: Sorry! You cannot use this command with the role **${bot.settings.support}**`) + .setColor(bot.settings.colour) + if (!message.member.roles.has(staffGroup.id)) return message.reply({embed: donothaverole}); + + const outsideticket = new Discord.RichEmbed() + .setDescription(`:x: Cannot use this command becase you are outside a ticket channel.`) + .setColor(bot.settings.colour) + if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send({embed: outsideticket}); + const renameto = args.join(" ") + message.channel.setName(`ticket-${renameto}-${message.author.username}`) + + // Renamed Ticket Logistic + const logEmbed = new Discord.RichEmbed() + .setTitle(":ticket: Ticket Renamed") + .setDescription(`<@${message.author.id}> has renamed a ticket to ${renameto}`) + .setColor(bot.settings.colour) + .setFooter(bot.settings.footer) + + let logChannel = message.guild.channels.find(TicketChannel => TicketChannel.name === `${bot.settings.Ticket_Logs}`); + if(!logChannel) return message.channel.send(`:x: Error! Could not find the logs channel **${bot.settings.Ticket_Logs}**`); + + logChannel.send({embed: logEmbed}) + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Rename_Command}`) + +} + +exports.help = { + name: bot.settings.Rename_Command, +} \ No newline at end of file diff --git a/commands/say.js b/commands/say.js new file mode 100644 index 0000000..41810d4 --- /dev/null +++ b/commands/say.js @@ -0,0 +1,42 @@ +// SupportBot +// Command: Say + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = (bot, message, args) => { + message.delete(); + + let staffGroup = message.guild.roles.find(staffRole => staffRole.name === `${bot.settings.staff}`) + + const rolemissing = new Discord.RichEmbed() + .setDescription(`:x: Looks like this server doesn't have the role **${bot.settings.staff}**`) + .setColor(bot.settings.colour) + if (!staffGroup) return message.reply(rolemissing).catch(err=>{console.error(err)}) + + const donothaverole = new Discord.RichEmbed() + .setDescription(`:x: Sorry! You cannot use this command with the role **${bot.settings.staff}**`) + .setColor(bot.settings.colour) + if (!message.member.roles.has(staffGroup.id)) return message.reply(donothaverole) + + const embed = new Discord.RichEmbed() + .setTitle(`${bot.settings.Announcement_Title}`) + .setDescription(args.join(" ")) + .setTimestamp() + .setColor(bot.settings.colour) +.setFooter(`${message.author.username}#${message.author.discriminator}`, message.author.displayAvatarURL) + + let ac = message.guild.channels.find(AnnounceChannel => AnnounceChannel.name === `${bot.settings.Announcement_Channel}`) + if(!ac) return message.channel.send(`:x: Error! Could not find the logs channel **${bot.settings.Announcement_Channel}**`) + + ac.send(embed) + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Say_Command}`) + +} + +exports.help = { + name: bot.settings.Say_Command, +} \ No newline at end of file diff --git a/commands/suggest.js b/commands/suggest.js new file mode 100644 index 0000000..ef8cfac --- /dev/null +++ b/commands/suggest.js @@ -0,0 +1,33 @@ +// SupportBot +// Command: Suggest + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = async(bot, message, args) => { + message.delete(); + + const SuggestionEmbed = new Discord.RichEmbed() + .setTitle(`${bot.settings.Suggestion_Title}`) + .setDescription(args.join(" ")) + .setFooter(`Suggestion by ${message.author.username}`, message.author.displayAvatarURL) + .setColor(bot.settings.colour) + + let sc = message.guild.channels.find(SuggestionChannel => SuggestionChannel.name === `${bot.settings.Suggestion_Channel}`); + if(!sc) return message.channel.send(`:x: Error! Could not find the suggestion channel **${bot.settings.Suggestion_Channel}**`); + + sc.send(SuggestionEmbed) + + .then(async function(msg) { + msg.react(bot.settings.suggestyes).then(() => msg.react(bot.settings.suggestno)); + }); + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Suggest_Command}`) + +} + +exports.help = { + name: bot.settings.Suggest_Command, +} \ No newline at end of file diff --git a/commands/ticket.js b/commands/ticket.js new file mode 100644 index 0000000..392fafa --- /dev/null +++ b/commands/ticket.js @@ -0,0 +1,85 @@ +// SupportBot +// Command: Ticket + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = async(bot, message, args) => { + message.delete(); + + const ID = Math.floor(Math.random() * 10) + 2000; + const subject = args.join(" ") || "No Subject."; + + const alreadyopen = new Discord.RichEmbed() + .setDescription(`:x: Cannot create a ticket because **ticket-${message.author.username}** already exists.`) + .setColor(bot.settings.colour) + if (message.guild.channels.find(TicketChannel => TicketChannel.name === 'ticket-' + message.author.username)) return message.channel.send(alreadyopen); + message.guild.createChannel(`ticket-${message.author.username}`, 'text').then(TicketChannel => { + + // Roles + let staff = message.guild.roles.find(staffRole => staffRole.name === `${bot.settings.support}`) + let everyone = message.guild.roles.find(everyoneRole => everyoneRole.name === `@everyone`) + + // Permissions + TicketChannel.overwritePermissions(everyone, { SEND_MESSAGES: false, READ_MESSAGES: false }) + TicketChannel.overwritePermissions(staff, { SEND_MESSAGES: true, READ_MESSAGES: true }) + TicketChannel.overwritePermissions(message.author, { SEND_MESSAGES: true, READ_MESSAGES: true }) + TicketChannel.overwritePermissions(bot.user, { SEND_MESSAGES: true, READ_MESSAGES: true }) + + // Category + let category = message.guild.channels.find(c => c.name === bot.settings.category); + if (category) { + TicketChannel.setParent(category.id); + } else { + if (message.guild.channels.get(bot.settings.category)) { + TicketChannel.setParent(message.guild.channels.get(bot.settings.category).id); + } + } + + const ticketopened = new Discord.RichEmbed() + .setDescription(`:white_check_mark: <@${message.author.id}> You ticket has been created <#${TicketChannel.id}>`) + .setColor(bot.settings.colour) + message.channel.send({embed: ticketopened}); + + // Ticket Message - ( Able to edit this message via the settings.json file ) + const ticketMessage = `Hi! <@${message.author.id}>\n${bot.settings.Ticket_Message}`; + + const TicketMessage = new Discord.RichEmbed() + .setDescription(ticketMessage) + .setColor(bot.settings.colour) + .setFooter(bot.settings.footer) + TicketChannel.send({embed: TicketMessage}); + + if (subject != 'No Subject.') { + TicketChannel.setTopic(subject); + } + + // Ticket Logging + const logEmbed = new Discord.RichEmbed() + .setTitle(":ticket: Logistics of your Ticket") + .addField("Ticket ID", ID, true) + .addField("User", `<@${message.author.id}>`, true) + .addField("Channel", `ticket#${ID}`, true) + .setColor(bot.settings.colour) + .setFooter(bot.settings.footer) + + if (subject != 'No Subject.') { + logEmbed.addField('Subject', subject, true); + } + + let logChannel = message.guild.channels.find(TicketChannel => TicketChannel.name === `${bot.settings.Ticket_Logs}`); + if(!logChannel) return message.channel.send(`:x: Error! Could not find the logs channel **${bot.settings.Ticket_Logs}**`); + + logChannel.send({embed: logEmbed}) + + }).catch(err=>{console.error(err)}); + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.Ticket_Command}`) + +} + +exports.help = { + name: bot.settings.Ticket_Command, +} \ No newline at end of file diff --git a/commands/unlock.js b/commands/unlock.js new file mode 100644 index 0000000..93b52f2 --- /dev/null +++ b/commands/unlock.js @@ -0,0 +1,38 @@ +// SupportBot +// Command: Lockchat + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = async(bot, message, args) => { + message.delete(); + + let staffGroup = message.guild.roles.find(staffRole => staffRole.name === `${bot.settings.staff}`) + let everyoneRole = message.guild.roles.find(everyone => everyone.name === `${bot.settings.everyone}`) + + const rolemissing = new Discord.RichEmbed() + .setDescription(`:x: Looks like this server doesn't have the role **${bot.settings.staff}**`) + .setColor(bot.settings.colour) + if (!staffGroup) return message.reply(rolemissing).catch(err=>{console.error(err)}) + + const donothaverole = new Discord.RichEmbed() + .setDescription(`:x: Sorry! You cannot use this command with the role **${bot.settings.staff}**`) + .setColor(bot.settings.colour) + if (!message.member.roles.has(staffGroup.id)) return message.reply(donothaverole) + + message.channel.overwritePermissions(everyoneRole, { READ_MESSAGES: true, SEND_MESSAGES: true }); + + const lockmsg = new Discord.RichEmbed() + .setDescription(":white_check_mark: **Chat Un-Locked**") + .setColor(bot.settings.colour) + message.channel.send(lockmsg) + + console.log(`\x1b[36m`, `${message.author} has executed ${bot.settings.prefix}${bot.settings.UnLockchat_Command}`) + +} + +exports.help = { + name: bot.settings.UnLockchat_Command, +} \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..1aef57a --- /dev/null +++ b/index.js @@ -0,0 +1,102 @@ +// Resource: SupportBot +// Developed by Emerald +// Version: 3.4 + +const Discord = require("discord.js"); +const fs = require("fs"); +const bot = new Discord.Client(); + +bot.commands = new Discord.Collection(); +bot.settings = require("./settings.json"); + +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(`${bot.settings.botname} No commands found. Try to Re-download the resource`); + + jsfile.forEach((f, i) =>{ + let props = require(`./commands/${f}`); + console.log(`[${bot.settings.botname}] > Command Loaded > ${f}`); + bot.commands.set(props.help.name, props); + }); + + }); + +bot.addons = new Discord.Collection(); + +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(`${bot.settings.botname} No addons detected nor default! Either download addons from https://itzemerald.tk/`); + + jsfile.forEach((f, i) =>{ + let props = require(`./sb-addons/${f}`); + console.log(`[${bot.settings.botname}] > Addons Loaded > ${f}`); + bot.addons.set(props.help.name, props); + }); + + }); + +bot.on("ready", async () => { + bot.user.setActivity(bot.settings.BotStatus, {type:"PLAYING"}); + console.log(`\x1b[36m`, `=== [SupportBot] ===\n\nSupportBot - Created by Emerald Services\nInvite ${bot.user.username} to your server\nhttps://discordapp.com/api/oauth2/authorize?client_id=${bot.user.username}&permissions=8&scope=bot\n\n=== [SupportBot] ===`) +}); + +bot.on("message", async message => { + if(message.author.bot) return; + if(message.channel.type === "dm") return; + if (message.content.indexOf(bot.settings.prefix) !== 0) return; + + let messageArray = message.content.split(" "); + const args = message.content.slice(bot.settings.prefix.length).trim().split(/ +/g); + const command = args.shift().toLowerCase(); + + const cmd = bot.commands.get(command); + if(!cmd) return; + cmd.run(bot, message, args); +}); + +bot.on("message", async message => { +if(message.author.bot) return; +if(message.channel.type === "dm") return; +if (message.content.indexOf(bot.settings.prefix) !== 0) return; + +let messageArray = message.content.split(" "); +const args = message.content.slice(bot.settings.prefix.length).trim().split(/ +/g); +const addon = args.shift().toLowerCase(); + +const cmd = bot.addons.get(addon); +if(!cmd) return; +cmd.run(bot, message, args); +}); + +// [SupportBot] Welcome Message + +bot.on("guildMemberAdd", (member) => { + let channel = member.guild.channels.find(channel => channel.name === `${bot.settings.Welcome_Channel}`) + + const WelcomeMsg= new Discord.RichEmbed() + .setColor(bot.settings.colour) + .setThumbnail(member.user.avatarURL) + .setDescription(`:wave: ${member.user.username}\n${bot.settings.Welcome_Message}`) + + channel.send(WelcomeMsg); +}); + +// [SupportBot] Leave Message + +bot.on("guildMemberRemove", (member) => { + let channel = member.guild.channels.find(channel => channel.name === `${bot.settings.Leave_Channel}`) + + const LeaveMsg= new Discord.RichEmbed() + .setColor(bot.settings.colour) + .setThumbnail(member.user.avatarURL) + .setDescription(`:wave: ${member.user.username}\n${bot.settings.Leave_Message}`) + + channel.send(LeaveMsg); + +}); + +bot.login(bot.settings.token); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..96b3179 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "supportbot", + "version": "3.4", + "description": "SupportBot", + "main": "index.js", + "dependencies": { + "discord.js": "^11.4.2" + }, + "devDependencies": {}, + "scripts": { + "test": "!help" + }, + "keywords": [ + "SupportBot" + ], + "author": "Emerald Services", + "homepage": "https://discord.gg/hmWgxdF" +} diff --git a/sb-addons/default-addon.js b/sb-addons/default-addon.js new file mode 100644 index 0000000..a10eb57 --- /dev/null +++ b/sb-addons/default-addon.js @@ -0,0 +1,18 @@ +// SupportBot Addons +// Default Addon + +const Discord = require("discord.js"); +const bot = new Discord.Client() + +bot.settings = require("../settings.json"); + +exports.run = async(bot, message, args) => { + message.delete(); + + message.channel.send(":white_check_mark: **SupportBot Addon**\nThis addon is here by default.\nWe are currently working on some super amazing addons for SupportBot\nHowever, If you would like to start creating your own support bot addon\ncontact us at EmeraldServices.\n") + +} + +exports.help = { + name: 'addon', +} \ No newline at end of file diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..bd69563 --- /dev/null +++ b/settings.json @@ -0,0 +1,65 @@ +{ + +"SupportBot": "v3.4 / Download addons @ https://itzemerald.tk/", + +"token": "NTY1ODkzODk3NzU5MzU4OTgy.XO2XMw.iIUiQEyfAzkV2o8hApvQRQpRg80", +"prefix": "!", +"botname": "SupportBot", +"colour": "#42f477", +"footer": "Support Bot, By Emerald", + +"BotStatus": "Support Bot", + +"staff": "Staff", +"support": "Support Team", +"everyone": "@everyone", + +"category": "Tickets", +"Ticket_Message": "Your support ticket has been opened successfully\nPlease allow us some time to reach out to you.", +"Ticket_Logs": "ticket-logs", + +"Announcement_Title": "SupportBot Announcement", +"Announcement_Channel": "announcements", + +"Welcome_Message": "Welcome to the server!", +"Welcome_Channel": "welcome", + +"Leave_Message": "Thank you for visiting us!", +"Leave_Channel": "welcome", + +"Poll_Channel": "polls", +"Poll_Title": "📊 Polls", +"Reaction_Poll_1": "✅", +"Reaction_Poll_2": "❎", + +"Suggestion_Title": "SupportBot Suggestions", +"Suggestion_Channel": "suggestions", +"suggestyes": "✅", +"suggestno": "❎", + +"LINK_1_NAME": "Discord", +"LINK_2_NAME": "Twitter", +"LINK_3_NAME": "Website", + +"LINK_1": "https://dicord.gg/changemeinconfig", +"LINK_2": "https://twitter.com/changemeinconfig", +"LINK_3": "https://www.example.com/", + +"LINKS_TITLE": "SupportBot Links", + +"Ticket_Command": "ticket", +"Suggest_Command": "suggest", +"Say_Command": "say", +"Remove_Command": "remove", +"Add_Command": "add", +"Ping_Command": "ping", +"Close_Command": "close", +"Forceclose_Command": "forceclose", +"Rename_Command": "rename", +"Help_Command": "help", +"Link_Command": "links", +"Lockchat_Command": "lock", +"UnLockchat_Command": "unlock", +"Poll_Command": "poll" + +} diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..e8059e0 --- /dev/null +++ b/start.bat @@ -0,0 +1,2 @@ +node index.js +pause \ No newline at end of file