From f7254c7ec7427a91f9d099f4fd6148487b1acde8 Mon Sep 17 00:00:00 2001 From: ItzEmerald Date: Sat, 20 Jun 2020 00:10:38 +0100 Subject: [PATCH] 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