7.1 Pre-1
Revamp of ticket system
This commit is contained in:
1 parent
3d9c5a729e
commit
4125954d53
10 files changed
+284
-309
No files matched your search
+16
-16
@@ -58,18 +58,18 @@ module.exports = {
|
|||||||
.addField("Reason", reason);
|
.addField("Reason", reason);
|
||||||
|
|
||||||
message.channel.messages.fetch({ limit: 100 }).then( msgs => {
|
message.channel.messages.fetch({ limit: 100 }).then( msgs => {
|
||||||
let txt = '';
|
let html = '';
|
||||||
|
|
||||||
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp );
|
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp );
|
||||||
txt += `${message.guild.name}\n`;
|
html += `<strong>Server Name:</strong> ${message.guild.name}<br>`;
|
||||||
txt += `#${ticketChannel.name}\n`;
|
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
|
||||||
txt += `${msgs.size} messages\n\n\n`;
|
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
|
||||||
|
|
||||||
msgs.forEach( msg => {
|
msgs.forEach( msg => {
|
||||||
if ( msg.content ) {
|
if ( msg.content ) {
|
||||||
txt += `----- ${msg.author.tag} at ${msg.createdAt}\n`;
|
html += `<strong>User:</strong> ${msg.author.tag}<br>`;
|
||||||
txt += `${msg.content}\n`;
|
html += `<strong>Message:</strong> ${msg.content}<br>`;
|
||||||
txt += `-----\n\n`;
|
html += `-----<br><br>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ module.exports = {
|
|||||||
message.reply(err)
|
message.reply(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
logChannel.send( new Discord.MessageAttachment( Buffer.from( txt ), `${name}.txt` ) );
|
logChannel.send( new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` ) );
|
||||||
|
|
||||||
message.channel.delete();
|
message.channel.delete();
|
||||||
|
|
||||||
@@ -112,18 +112,18 @@ module.exports = {
|
|||||||
.addField("Reason", reason);
|
.addField("Reason", reason);
|
||||||
|
|
||||||
message.channel.messages.fetch({ limit: 100 }).then( msgs => {
|
message.channel.messages.fetch({ limit: 100 }).then( msgs => {
|
||||||
let txt = '';
|
let html = '';
|
||||||
|
|
||||||
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp );
|
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp );
|
||||||
txt += `${message.guild.name}\n`;
|
html += `<strong>Server Name:</strong> ${message.guild.name}<br>`;
|
||||||
txt += `#${ticketChannel.name}\n`;
|
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
|
||||||
txt += `${msgs.size} messages\n\n\n`;
|
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
|
||||||
|
|
||||||
msgs.forEach( msg => {
|
msgs.forEach( msg => {
|
||||||
if ( msg.content ) {
|
if ( msg.content ) {
|
||||||
txt += `----- ${msg.author.tag} at ${msg.createdAt}\n`;
|
html += `<strong>User:</strong> ${msg.author.tag}<br>`;
|
||||||
txt += `${msg.content}\n`;
|
html += `<strong>Message:</strong> ${msg.content}<br>`;
|
||||||
txt += `-----\n\n`;
|
html += `-----<br><br>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ module.exports = {
|
|||||||
message.reply(err)
|
message.reply(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
logChannel.send( new Discord.MessageAttachment( Buffer.from( txt ), `${name}.txt` ) );
|
logChannel.send( new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` ) );
|
||||||
|
|
||||||
message.channel.delete();
|
message.channel.delete();
|
||||||
|
|
||||||
|
|||||||
@@ -1,281 +0,0 @@
|
|||||||
// SupportBot, Created by Emerald Services
|
|
||||||
// Ticket Command
|
|
||||||
|
|
||||||
|
|
||||||
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');
|
|
||||||
|
|
||||||
const reacted = [];
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: supportbot.NewTicket,
|
|
||||||
description: supportbot.NewTicketDesc,
|
|
||||||
|
|
||||||
execute(message, args) {
|
|
||||||
if (!message.channel.name === supportbot.ReactionChannel || !message.channel.id === supportbot.ReactionChannel) {
|
|
||||||
if (supportbot.DeleteMessages) message.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
let reactionUser = message.guild.members.cache.get(message.author.id)
|
|
||||||
|
|
||||||
if (reactionUser.roles.cache.find(role => role.name === supportbot.TicketBlackListRole) || reactionUser.roles.cache.find(role => role.id === supportbot.TicketBlackListRole)) {
|
|
||||||
return message.channel.send(`<@${message.author.id}> ${supportbot.TicketBlackListMessage}`).then(msg => {
|
|
||||||
msg.delete({timeout: 3500})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ticket ID
|
|
||||||
let ticketNumberID = TicketNumberID.pad(message.guild.id);
|
|
||||||
|
|
||||||
// Ticket Subject
|
|
||||||
const TicketSubject = args || supportbot.NoTicketSubject;
|
|
||||||
|
|
||||||
// Ticket Exists
|
|
||||||
const TicketExists = new Discord.MessageEmbed()
|
|
||||||
.setTitle("Ticket Exists!")
|
|
||||||
.setDescription(`${supportbot.TicketExists}`)
|
|
||||||
.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",
|
|
||||||
permissionOverwrites: [
|
|
||||||
{
|
|
||||||
id: message.guild.roles.everyone,
|
|
||||||
deny: ['VIEW_CHANNEL'],
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}).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) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff)
|
|
||||||
let Admins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin)
|
|
||||||
|
|
||||||
let DeptRole1 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_1}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_1}`)
|
|
||||||
let DeptRole2 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_2}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_2}`)
|
|
||||||
let DeptRole3 = message.guild.roles.cache.find(DepartmentRole => DepartmentRole.name === `${supportbot.DepartmentRole_3}`) || message.guild.roles.cache.find(DepartmentRole => DepartmentRole.id === `${supportbot.DepartmentRole_3}`)
|
|
||||||
|
|
||||||
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,
|
|
||||||
})
|
|
||||||
|
|
||||||
SupportTicket.updateOverwrite(AllUsers, {
|
|
||||||
VIEW_CHANNEL: false
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Ticket Category
|
|
||||||
let TicketCategory = message.guild.channels.cache.find(category => category.name === supportbot.TicketCategory) || message.guild.channels.cache.find(category => category.id === supportbot.TicketCategory)
|
|
||||||
|
|
||||||
if (TicketCategory) {
|
|
||||||
SupportTicket.setParent(TicketCategory.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ticket Created, Message Sent
|
|
||||||
|
|
||||||
if (supportbot.AllowTicketMentions) {
|
|
||||||
SupportTicket.send(`<@${message.author.id}>`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const TicketMessage = new Discord.MessageEmbed()
|
|
||||||
.setTitle(supportbot.Ticket_Title.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, SupportTicket.id).replace(/%ticketusername%/g, message.author.username))
|
|
||||||
.setDescription(supportbot.TicketMessage.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, SupportTicket.id).replace(/%ticketusername%/g, message.author.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) {
|
|
||||||
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;
|
|
||||||
|
|
||||||
reacted[ticketNumberID] = false;
|
|
||||||
|
|
||||||
if (supportbot.TicketDepartments) {
|
|
||||||
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) {
|
|
||||||
SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, })
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!supportbot.AllowStaff) {
|
|
||||||
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)
|
|
||||||
SupportTicket.send({ embed: Department1 });
|
|
||||||
|
|
||||||
if (supportbot.AllowTicketMentions) {
|
|
||||||
SupportTicket.send(`@here`)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, })
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!supportbot.AllowStaff) {
|
|
||||||
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.`)
|
|
||||||
.setColor(supportbot.EmbedColour)
|
|
||||||
SupportTicket.send({ embed: Department2 });
|
|
||||||
|
|
||||||
if (supportbot.AllowTicketMentions) {
|
|
||||||
SupportTicket.send(`@here`)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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, })
|
|
||||||
SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: false, READ_MESSAGES: true, SEND_MESSAGES: true, })
|
|
||||||
|
|
||||||
if (supportbot.AllowStaff) {
|
|
||||||
SupportTicket.updateOverwrite(SupportStaff, { VIEW_CHANNEL: true, READ_MESSAGES: true, SEND_MESSAGES: true, })
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!supportbot.AllowStaff) {
|
|
||||||
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.`)
|
|
||||||
.setColor(supportbot.EmbedColour)
|
|
||||||
SupportTicket.send({ embed: Department3 });
|
|
||||||
|
|
||||||
if (supportbot.AllowTicketMentions) {
|
|
||||||
SupportTicket.send(`@here`)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
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() {
|
|
||||||
if (typeof reacted[ticketNumberID] == "boolean") {
|
|
||||||
delete reacted[ticketNumberID];
|
|
||||||
//delete channel because didn't react in a minute
|
|
||||||
}
|
|
||||||
}, 60000);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
if (message.channel.name === supportbot.ReactionChannel || message.channel.id === supportbot.ReactionChannel) {
|
|
||||||
const CreatedTicket = new Discord.MessageEmbed()
|
|
||||||
.setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, SupportTicket.id).replace(/%ticketusername%/g, message.author.username))
|
|
||||||
.setColor(supportbot.EmbedColour)
|
|
||||||
message.channel.send({embed: CreatedTicket}).then((r) => {
|
|
||||||
r.delete({ timeout:5000 })
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
const CreatedTicket = new Discord.MessageEmbed()
|
|
||||||
.setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, SupportTicket.id).replace(/%ticketusername%/g, message.author.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) || message.guild.channels.cache.find(LocateChannel => LocateChannel.id === supportbot.TicketLog)
|
|
||||||
|
|
||||||
if(!locateChannel) return message.channel.send({ embed: errornochannel });
|
|
||||||
|
|
||||||
locateChannel.send({ embed: TicketLogs });
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
// SupportBot, Created by Emerald Services
|
||||||
|
// Ticket Command
|
||||||
|
|
||||||
|
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,
|
||||||
|
description: supportbot.NewTicketDesc,
|
||||||
|
|
||||||
|
async execute(message, args) {
|
||||||
|
if (!message.channel.name === supportbot.ReactionChannel || !message.channel.id === supportbot.ReactionChannel) {
|
||||||
|
if (supportbot.DeleteMessages) message.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
let reactionUser = message.guild.members.cache.get(message.author.id)
|
||||||
|
|
||||||
|
if (reactionUser.roles.cache.find(role => role.name === supportbot.TicketBlackListRole) || reactionUser.roles.cache.find(role => role.id === supportbot.TicketBlackListRole)) {
|
||||||
|
return message.channel.send(`<@${message.author.id}> ${supportbot.TicketBlackListMessage}`).then(msg => {
|
||||||
|
msg.delete({timeout: 3500})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ticket ID
|
||||||
|
let ticketNumberID = TicketNumberID.pad(message.guild.id);
|
||||||
|
|
||||||
|
// Ticket Subject
|
||||||
|
const TicketSubject = args || supportbot.NoTicketSubject;
|
||||||
|
|
||||||
|
const channel = await message.guild.channels.create(`${supportbot.TicketChannel}-${ticketNumberID}`);
|
||||||
|
|
||||||
|
if (message.channel.name === supportbot.ReactionChannel || message.channel.id === supportbot.ReactionChannel) {
|
||||||
|
const CreatedTicket = new Discord.MessageEmbed()
|
||||||
|
.setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, channel.id).replace(/%ticketusername%/g, message.author.username))
|
||||||
|
.setColor(supportbot.EmbedColour)
|
||||||
|
message.channel.send({embed: CreatedTicket}).then((r) => {
|
||||||
|
r.delete({ timeout:5000 })
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const CreatedTicket = new Discord.MessageEmbed()
|
||||||
|
.setDescription(supportbot.TicketCreatedAlert.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, channel.id).replace(/%ticketusername%/g, message.author.username))
|
||||||
|
.setColor(supportbot.EmbedColour)
|
||||||
|
message.channel.send({embed: CreatedTicket});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ticket Category
|
||||||
|
let TicketCategory = message.guild.channels.cache.find(category => category.name === supportbot.TicketCategory) || message.guild.channels.cache.find(category => category.id === supportbot.TicketCategory)
|
||||||
|
|
||||||
|
// Locate Roles
|
||||||
|
let StaffMember = message.guild.roles.cache.find(SupportTeam => SupportTeam.name === supportbot.Staff) || message.guild.roles.cache.find(SupportTeam => SupportTeam.id === supportbot.Staff)
|
||||||
|
let ServerAdmins = message.guild.roles.cache.find(AdminUser => AdminUser.name === supportbot.Admin) || message.guild.roles.cache.find(AdminUser => AdminUser.id === supportbot.Admin)
|
||||||
|
|
||||||
|
if (TicketCategory) {
|
||||||
|
channel.setParent(TicketCategory.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
channel.updateOverwrite(message.guild.id, {
|
||||||
|
SEND_MESSAGES: false,
|
||||||
|
VIEW_CHANNEL: false
|
||||||
|
})
|
||||||
|
|
||||||
|
channel.updateOverwrite(message.author, {
|
||||||
|
SEND_MESSAGES: true,
|
||||||
|
VIEW_CHANNEL: true
|
||||||
|
})
|
||||||
|
|
||||||
|
channel.updateOverwrite(StaffMember, {
|
||||||
|
SEND_MESSAGES: true,
|
||||||
|
VIEW_CHANNEL: true
|
||||||
|
})
|
||||||
|
|
||||||
|
channel.updateOverwrite(ServerAdmins, {
|
||||||
|
SEND_MESSAGES: true,
|
||||||
|
VIEW_CHANNEL: true
|
||||||
|
})
|
||||||
|
|
||||||
|
// Ticket Created, Message Sent
|
||||||
|
|
||||||
|
if (supportbot.AllowTicketMentions) {
|
||||||
|
channel.send(`<@${message.author.id}>`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const TicketMessage = new Discord.MessageEmbed()
|
||||||
|
.setTitle(supportbot.Ticket_Title.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, channel.id).replace(/%ticketusername%/g, message.author.username))
|
||||||
|
.setDescription(supportbot.TicketMessage.replace(/%ticketauthor%/g, message.author.id).replace(/%ticketid%/g, channel.id).replace(/%ticketusername%/g, message.author.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.') {
|
||||||
|
channel.setTopic(`Reason: ${TicketSubject} - User ID: ${message.author.id} - Ticket: ${channel.name}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const reactionMessage = await channel.send({
|
||||||
|
embed: TicketMessage
|
||||||
|
}).then( async function(ticketmsg) {
|
||||||
|
await ticketmsg.react(supportbot.TicketLockReaction)
|
||||||
|
await ticketmsg.react(supportbot.TicketDeleteReaction)
|
||||||
|
|
||||||
|
const collector = ticketmsg.createReactionCollector(
|
||||||
|
(reaction, user) => message.guild.roles.cache.find((staff) => staff.name === supportbot.Staff),
|
||||||
|
{ dispose: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
collector.on('collect', (reaction, user) => {
|
||||||
|
switch (reaction.emoji.name) {
|
||||||
|
case supportbot.TicketLockReaction:
|
||||||
|
|
||||||
|
channel.updateOverwrite(message.author, {
|
||||||
|
SEND_MESSAGES: false,
|
||||||
|
VIEW_CHANNEL: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const LockTicketEmbed = new Discord.MessageEmbed()
|
||||||
|
.setDescription(supportbot.TicketLockMessage)
|
||||||
|
.setColor(supportbot.EmbedColour)
|
||||||
|
channel.send({embed: LockTicketEmbed})
|
||||||
|
break;
|
||||||
|
|
||||||
|
case supportbot.TicketDeleteReaction:
|
||||||
|
const DeleteTicketEmbed = new Discord.MessageEmbed()
|
||||||
|
.setDescription(supportbot.TicketDeleteMessage)
|
||||||
|
.setColor(supportbot.EmbedColour)
|
||||||
|
channel.send({embed: DeleteTicketEmbed})
|
||||||
|
|
||||||
|
let logChannel = message.guild.channels.cache.find(channel => channel.name === supportbot.TranscriptLog) || message.guild.channels.cache.find(channel => channel.id === 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 html = '';
|
||||||
|
|
||||||
|
msgs = msgs.sort( ( a, b ) => a.createdTimestamp - b.createdTimestamp );
|
||||||
|
html += `<strong>Server Name:</strong> ${message.guild.name}<br>`;
|
||||||
|
html += `<strong>Ticket:</strong> ${ticketChannel.name}<br>`;
|
||||||
|
html += `<strong>Message:</strong> ${msgs.size} Messages<br><br><br>`;
|
||||||
|
|
||||||
|
msgs.forEach( msg => {
|
||||||
|
if ( msg.content ) {
|
||||||
|
html += `<strong>User:</strong> ${msg.author.tag}<br>`;
|
||||||
|
html += `<strong>Message:</strong> ${msg.content}<br>`;
|
||||||
|
html += `-----<br><br>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
logChannel.send(logEmbed).catch(err => {
|
||||||
|
message.reply(err)
|
||||||
|
})
|
||||||
|
|
||||||
|
const TranscriptSavedEmbed = new Discord.MessageEmbed()
|
||||||
|
.setDescription(supportbot.TranscriptSavedMessage)
|
||||||
|
.setColor(supportbot.SuccessColour)
|
||||||
|
channel.send({embed: TranscriptSavedEmbed})
|
||||||
|
|
||||||
|
logChannel.send( new Discord.MessageAttachment( Buffer.from( html ), `${name}.html` ) );
|
||||||
|
setTimeout(() => channel.delete(), supportbot.TicketDeleteTime);
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}).catch( () => {
|
||||||
|
m.edit('The request to close the ticket has timed out.').then( m2 => m2.delete( 3000 ) );
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
fs.writeFileSync("./storage/SupportTickets.json", '{\n "ticket": "' + channel.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: `<#${channel.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) || message.guild.channels.cache.find(LocateChannel => LocateChannel.id === supportbot.TicketLog)
|
||||||
|
|
||||||
|
if(!locateChannel) return message.channel.send({ embed: errornochannel });
|
||||||
|
|
||||||
|
locateChannel.send({ embed: TicketLogs });
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
+1
-1
@@ -27,7 +27,7 @@ module.exports = async (bot) => {
|
|||||||
console.log(` `)
|
console.log(` `)
|
||||||
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`)
|
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`)
|
||||||
console.log(` `)
|
console.log(` `)
|
||||||
console.log(`\u001b[33m`, `${supportbot.Bot_Name}`, `\u001b[36m`, `Connected to Discord`)
|
console.log(`\u001b[33m`, `${supportbot.Bot_Name} v${supportbot.SupportBot_Version}`, `\u001b[36m`, `Connected to Discord`)
|
||||||
console.log(`\u001b[33m`, `Documentation:`, `\u001b[36m`, `https://docs.emeraldsrv.dev`)
|
console.log(`\u001b[33m`, `Documentation:`, `\u001b[36m`, `https://docs.emeraldsrv.dev`)
|
||||||
console.log(`\u001b[33m`, `Discord:`, `\u001b[36m`, `https://emeraldsrv.dev/discord`)
|
console.log(`\u001b[33m`, `Discord:`, `\u001b[36m`, `https://emeraldsrv.dev/discord`)
|
||||||
console.log(`\u001b[33m`, `Hosting:`, `\u001b[36m`, `https://emeraldsrv.dev/hosting`)
|
console.log(`\u001b[33m`, `Hosting:`, `\u001b[36m`, `https://emeraldsrv.dev/hosting`)
|
||||||
|
|||||||
+12
-3
@@ -9,13 +9,13 @@
|
|||||||
#
|
#
|
||||||
# Discord Support: https://emeraldsrv.dev/discord
|
# Discord Support: https://emeraldsrv.dev/discord
|
||||||
|
|
||||||
SupportBot Version: "7.0"
|
SupportBot_Version: "7.1 pre-1"
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# General Configuration
|
# General Configuration
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
||||||
Token: "TOKEN HERE"
|
Token: "BOT_TOKEN_HERE"
|
||||||
Prefix: "!!"
|
Prefix: "!!"
|
||||||
Bot_Name: "SupportBot"
|
Bot_Name: "SupportBot"
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ TicketBlackListRole: "Blacklisted"
|
|||||||
# --- General Config ---
|
# --- General Config ---
|
||||||
# --- Start ---
|
# --- Start ---
|
||||||
|
|
||||||
TicketCategory: "Support Tickets"
|
TicketCategory: "▬▬ TICKETS ▬▬"
|
||||||
TicketChannel: "ticket"
|
TicketChannel: "ticket"
|
||||||
|
|
||||||
TicketLog: "ticket-logs"
|
TicketLog: "ticket-logs"
|
||||||
@@ -128,6 +128,15 @@ TicketCreatedAlert: ":ticket: Your support ticket has been created: <#%ticketid%
|
|||||||
AddedUser: "👍 <@%user%> has been added to this ticket"
|
AddedUser: "👍 <@%user%> has been added to this ticket"
|
||||||
RemovedUser: "👍 <@%user%> has been removed from this ticket"
|
RemovedUser: "👍 <@%user%> has been removed from this ticket"
|
||||||
|
|
||||||
|
|
||||||
|
TicketLockReaction: "🔒"
|
||||||
|
TicketDeleteReaction: "⛔"
|
||||||
|
|
||||||
|
TranscriptSavedMessage: "📝 **Transcript Saved!**"
|
||||||
|
TicketLockMessage: "❌ **Ticket Locked!**"
|
||||||
|
TicketDeleteMessage: "⚠ **Ticket Deleting!**" # Tickets deleting after 5 seconds by default.
|
||||||
|
TicketDeleteTime: 5000 # Time must be set in miliseconds.
|
||||||
|
|
||||||
# --- Closing Config ---
|
# --- Closing Config ---
|
||||||
# --- Start ---
|
# --- Start ---
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "supportbot",
|
"name": "supportbot",
|
||||||
"version": "7.0.0",
|
"version": "7.1-pre-1",
|
||||||
"description": "SupportBot, a free open-source discord ticket application with ease of use.",
|
"description": "SupportBot, a free open-source discord ticket application with ease of use.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^12.5.3",
|
"discord.js": "^12.5.3",
|
||||||
"js-yaml": "^4.1.0"
|
"js-yaml": "^4.1.0",
|
||||||
|
"jsdom": "^16.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1 +1,4 @@
|
|||||||
{}
|
{
|
||||||
|
"ticket": "ticket-0043",
|
||||||
|
"id":419821884431925260
|
||||||
|
}
|
||||||
@@ -1 +1,5 @@
|
|||||||
{}
|
{
|
||||||
|
"854057237495676938": {
|
||||||
|
"id": 44
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
ReactionMessage_ID: ''
|
ReactionMessage_ID: '872499225110396958'
|
||||||
+12
-3
@@ -9,13 +9,13 @@
|
|||||||
#
|
#
|
||||||
# Discord Support: https://emeraldsrv.dev/discord
|
# Discord Support: https://emeraldsrv.dev/discord
|
||||||
|
|
||||||
SupportBot Version: "7.0"
|
SupportBot_Version: "7.1 pre-1"
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# General Configuration
|
# General Configuration
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
||||||
Token: "TOKEN HERE"
|
Token: "BOT_TOKEN_HERE"
|
||||||
Prefix: "!!"
|
Prefix: "!!"
|
||||||
Bot_Name: "SupportBot"
|
Bot_Name: "SupportBot"
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ TicketBlackListRole: "Blacklisted"
|
|||||||
# --- General Config ---
|
# --- General Config ---
|
||||||
# --- Start ---
|
# --- Start ---
|
||||||
|
|
||||||
TicketCategory: "Support Tickets"
|
TicketCategory: "▬▬ TICKETS ▬▬"
|
||||||
TicketChannel: "ticket"
|
TicketChannel: "ticket"
|
||||||
|
|
||||||
TicketLog: "ticket-logs"
|
TicketLog: "ticket-logs"
|
||||||
@@ -128,6 +128,15 @@ TicketCreatedAlert: ":ticket: Your support ticket has been created: <#%ticketid%
|
|||||||
AddedUser: "👍 <@%user%> has been added to this ticket"
|
AddedUser: "👍 <@%user%> has been added to this ticket"
|
||||||
RemovedUser: "👍 <@%user%> has been removed from this ticket"
|
RemovedUser: "👍 <@%user%> has been removed from this ticket"
|
||||||
|
|
||||||
|
|
||||||
|
TicketLockReaction: "🔒"
|
||||||
|
TicketDeleteReaction: "⛔"
|
||||||
|
|
||||||
|
TranscriptSavedMessage: "📝 **Transcript Saved!**"
|
||||||
|
TicketLockMessage: "❌ **Ticket Locked!**"
|
||||||
|
TicketDeleteMessage: "⚠ **Ticket Deleting!**" # Tickets deleting after 5 seconds by default.
|
||||||
|
TicketDeleteTime: 5000 # Time must be set in miliseconds.
|
||||||
|
|
||||||
# --- Closing Config ---
|
# --- Closing Config ---
|
||||||
# --- Start ---
|
# --- Start ---
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user