Updated 5.2
This commit is contained in:
1 parent
8173c31a60
commit
f2de39de33
19 files changed
+269
-234
No files matched your search
+47
-33
@@ -1,6 +1,6 @@
|
||||
// SupportBot
|
||||
// Created by © 2020 Emerald Services
|
||||
// Command: Say
|
||||
// Command: Ticket
|
||||
|
||||
const Discord = require("discord.js");
|
||||
const bot = new Discord.Client();
|
||||
@@ -27,34 +27,34 @@ exports.run = async (bot, message, args) => {
|
||||
.setColor(supportbot.EmbedColour)
|
||||
|
||||
// Ticket Creation
|
||||
if (message.guild.channels.find(TicketChannel => TicketChannel.name === `${supportbot.Ticket_Channel_Name}-` + message.author.username)) return message.channel.send(alreadyopen);
|
||||
message.guild.createChannel(`${supportbot.Ticket_Channel_Name}-${ticketNumberID}`, {
|
||||
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.find(supportRole => supportRole.name === `${supportbot.StaffRole}`)
|
||||
let everyone = message.guild.roles.find(everyoneRole => everyoneRole.name === "@everyone")
|
||||
let department = message.guild.roles.find(DepartmentRole => DepartmentRole.name === `${supportbot.Department_Role_1}`)
|
||||
let department2 = message.guild.roles.find(DepartmentRole => DepartmentRole.name === `${supportbot.Department_Role_2}`)
|
||||
let department3 = message.guild.roles.find(DepartmentRole => DepartmentRole.name === `${supportbot.Department_Role_3}`)
|
||||
let staff = message.guild.roles.cache.find(supportRole => supportRole.name === `${supportbot.StaffRole}`)
|
||||
let everyone = message.guild.roles.cache.find(everyoneRole => everyoneRole.name === "@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.overwritePermissions(everyone, { SEND_MESSAGES: false, READ_MESSAGES: false })
|
||||
TicketChannel.overwritePermissions(department, { SEND_MESSAGES: false, READ_MESSAGES: false })
|
||||
TicketChannel.overwritePermissions(department2, { SEND_MESSAGES: false, READ_MESSAGES: false })
|
||||
TicketChannel.overwritePermissions(department3, { SEND_MESSAGES: false, READ_MESSAGES: false })
|
||||
TicketChannel.overwritePermissions(staff, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.overwritePermissions(message.author, { SEND_MESSAGES: false, READ_MESSAGES: true })
|
||||
TicketChannel.overwritePermissions(bot.user, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(everyone, { SEND_MESSAGES: false, READ_MESSAGES: false })
|
||||
TicketChannel.updateOverwrite(department, { SEND_MESSAGES: false, READ_MESSAGES: false })
|
||||
TicketChannel.updateOverwrite(department2, { SEND_MESSAGES: false, READ_MESSAGES: false })
|
||||
TicketChannel.updateOverwrite(department3, { SEND_MESSAGES: false, READ_MESSAGES: false })
|
||||
TicketChannel.updateOverwrite(staff, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(message.author, { SEND_MESSAGES: false, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(bot.user, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
|
||||
// Category
|
||||
let category = message.guild.channels.find(c => c.name === supportbot.category);
|
||||
let category = message.guild.channels.cache.find(c => c.name === supportbot.category);
|
||||
if (category) {
|
||||
TicketChannel.setParent(category.id);
|
||||
} else {
|
||||
if (message.guild.channels.get(supportbot.category)) {
|
||||
TicketChannel.setParent(message.guild.channels.get(supportbot.category).id);
|
||||
if (message.guild.channels.cache.get(supportbot.category)) {
|
||||
TicketChannel.setParent(message.guild.channels.cache.get(supportbot.category).id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ exports.run = async (bot, message, args) => {
|
||||
.setTitle(":white_check_mark: Support Ticket Created")
|
||||
.setDescription(`<@${message.author.id}> your support ticket created successfully`)
|
||||
.addField("Your Ticket:", `<#${TicketChannel.id}>`)
|
||||
.setColor(supportbot.Ticket_Colour)
|
||||
.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}`;
|
||||
@@ -99,24 +99,33 @@ exports.run = async (bot, message, args) => {
|
||||
const reaction = collected.first();
|
||||
|
||||
if (reaction.emoji.name === `${Emoji_1}`) {
|
||||
TicketChannel.overwritePermissions(staff, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.overwritePermissions(department, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(staff, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(department, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
|
||||
msg.channel.send("You have contacted out " + department + "\nPlease wait patiently for someone to reach out to you.")
|
||||
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.overwritePermissions(staff, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.overwritePermissions(department2, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(staff, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(department2, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
|
||||
msg.channel.send("You have contacted out " + department2 + "\nPlease wait patiently for someone to reach out to you.")
|
||||
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.overwritePermissions(staff, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.overwritePermissions(department3, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(staff, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
TicketChannel.updateOverwrite(department3, { SEND_MESSAGES: true, READ_MESSAGES: true })
|
||||
|
||||
msg.channel.send("You have contacted out " + department3 + "\nPlease wait patiently for someone to reach out to you.")
|
||||
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)
|
||||
}
|
||||
|
||||
});
|
||||
@@ -125,7 +134,7 @@ exports.run = async (bot, message, args) => {
|
||||
|
||||
// Ticket Logging
|
||||
const logEmbed = new Discord.MessageEmbed()
|
||||
.setTitle(":ticket: Logistics of your Ticket")
|
||||
.setTitle(":ticket: Ticket Log")
|
||||
.addField("Ticket ID", ticketNumberID, true)
|
||||
.addField("User", `<@${message.author.id}>`, true)
|
||||
.addField("Channel", `ticket#${ticketNumberID}`, true)
|
||||
@@ -136,10 +145,15 @@ exports.run = async (bot, message, args) => {
|
||||
logEmbed.addField('Subject', subject, true);
|
||||
}
|
||||
|
||||
let logChannel = message.guild.channels.find(TicketChannel => TicketChannel.name === `${supportbot.Ticket_Logs}`);
|
||||
if(!logChannel) return message.channel.send(`:x: Error! Could not find the logs channel **${supportbot.Ticket_Logs}**`);
|
||||
|
||||
logChannel.send({embed: logEmbed})
|
||||
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)});
|
||||
|
||||
|
||||
Reference in new issue
Block a user