New Departments

This commit is contained in:
Noah committed 2022-02-11 23:34:38 -06:00
1 parent aa48e28162
commit 3e066d08ce
3 files changed
+104 -99

No files matched your search

+58 -62
View File
@@ -31,6 +31,13 @@ module.exports = new Command({
permissions: ["SEND_MESSAGES"], permissions: ["SEND_MESSAGES"],
async run(interaction) { async run(interaction) {
let disableCommand = true;
if (interaction.isCommand() && disableCommand)
return interaction.reply({
content: "This command is disabled",
ephemeral: true,
});
let department = interaction.customId?.split("-")[1] || null;
let TicketData = await JSON.parse( let TicketData = await JSON.parse(
fs.readFileSync("./Data/TicketData.json", "utf8") fs.readFileSync("./Data/TicketData.json", "utf8")
); );
@@ -73,8 +80,7 @@ module.exports = new Command({
const TicketExists = new MessageEmbed() const TicketExists = new MessageEmbed()
.setTitle("Ticket Exists!") .setTitle("Ticket Exists!")
.setDescription(`${supportbot.TicketExists}`) .setDescription(`${supportbot.TicketExists}`);
.setColor(supportbot.WarningColour);
if ( if (
await interaction.guild.channels.cache.find( await interaction.guild.channels.cache.find(
@@ -89,19 +95,7 @@ module.exports = new Command({
} }
const Staff = await getRole(supportbot.Staff, interaction.guild); const Staff = await getRole(supportbot.Staff, interaction.guild);
const Admin = await getRole(supportbot.Admin, interaction.guild); const Admin = await getRole(supportbot.Admin, interaction.guild);
const DeptRole1 = await getRole( if (!Staff || !Admin)
supportbot.DepartmentRole_1,
interaction.guild
);
const DeptRole2 = await getRole(
supportbot.DepartmentRole_2,
interaction.guild
);
const DeptRole3 = await getRole(
supportbot.DepartmentRole_3,
interaction.guild
);
if (!Staff || !Admin || !DeptRole1 || !DeptRole2 || !DeptRole3)
return interaction.reply({ return interaction.reply({
content: content:
"Some roles seem to be missing!\nPlease check for errors when starting the bot.", "Some roles seem to be missing!\nPlease check for errors when starting the bot.",
@@ -109,7 +103,7 @@ module.exports = new Command({
}); });
const Author = interaction.user; const Author = interaction.user;
let TicketCategory = await getCategory( let TicketCategory = await getCategory(
supportbot.TicketCategory, supportbot.Departments[department].category || supportbot.TicketCategory,
interaction.guild interaction.guild
); );
const ticketChannel = await interaction.guild.channels.create( const ticketChannel = await interaction.guild.channels.create(
@@ -133,13 +127,13 @@ module.exports = new Command({
], ],
} }
); );
if (supportbot.AllowStaff) { if (supportbot.AllowAllStaff) {
ticketChannel.permissionOverwrites.edit(Staff.id, { await ticketChannel.permissionOverwrites.edit(Staff.id, {
VIEW_CHANNEL: true, VIEW_CHANNEL: true,
}); });
} }
if (supportbot.TicketDepartments) { if (supportbot.TicketDepartments && !department) {
ticketChannel.permissionOverwrites.edit(interaction.user.id, { await ticketChannel.permissionOverwrites.edit(interaction.user.id, {
SEND_MESSAGES: false, SEND_MESSAGES: false,
}); });
} }
@@ -203,10 +197,10 @@ module.exports = new Command({
} }
} }
if (supportbot.TicketDepartments) { if (supportbot.TicketDepartments && !department) {
TicketMessage.addFields({ TicketMessage.addFields({
name: "Departments", name: "Departments",
value: ` **${supportbot.DepartmentTitle_1}**\n **${supportbot.DepartmentTitle_2}**\n **${supportbot.DepartmentTitle_3}**`, value: ` **${supportbot.Departments.map((X) => X.title).join("\n")}**`,
}); });
} }
const CloseButton = new MessageButton() const CloseButton = new MessageButton()
@@ -222,33 +216,16 @@ module.exports = new Command({
.setEmoji(supportbot.TicketLockEmoji); .setEmoji(supportbot.TicketLockEmoji);
const row2 = new MessageActionRow().addComponents(CloseButton, LockButton); const row2 = new MessageActionRow().addComponents(CloseButton, LockButton);
if (supportbot.TicketDepartments && !department) {
if (supportbot.TicketDepartments) {
try { try {
const Department1Button = new MessageButton() let buttons = await supportbot.Departments.map((x) =>
.setCustomId("Department1") new MessageButton()
.setLabel(supportbot.DepartmentTitle_1) .setCustomId("Department" + supportbot.Departments.indexOf(x))
.setStyle(supportbot.TicketDept1Colour) .setLabel(x.title)
.setEmoji(supportbot.TicketDept1Emoji); .setStyle(x.color)
.setEmoji(x.emoji)
const Department2Button = new MessageButton()
.setCustomId("Department2")
.setLabel(supportbot.DepartmentTitle_2)
.setStyle(supportbot.TicketDept2Colour)
.setEmoji(supportbot.TicketDept2Emoji);
const Department3Button = new MessageButton()
.setCustomId("Department3")
.setLabel(supportbot.DepartmentTitle_3)
.setStyle(supportbot.TicketDept3Colour)
.setEmoji(supportbot.TicketDept3Emoji);
const row = new MessageActionRow().addComponents(
Department1Button,
Department2Button,
Department3Button
); );
const row = new MessageActionRow().addComponents(buttons);
const m = await ticketChannel.send({ const m = await ticketChannel.send({
embeds: [TicketMessage], embeds: [TicketMessage],
components: [row], components: [row],
@@ -287,20 +264,9 @@ module.exports = new Command({
return await ticketChannel.delete(); return await ticketChannel.delete();
} }
} }
let role; let num = collector.customId.split("Department")[1];
let title; let role = getRole(supportbot.Departments[num].role, interaction.guild);
if (collector.customId === "Department1") { let title = supportbot.Departments[num].title;
role = DeptRole1;
title = supportbot.DepartmentTitle_1;
}
if (collector.customId === "Department2") {
role = DeptRole2;
title = supportbot.DepartmentTitle_2;
}
if (collector.customId === "Department3") {
role = DeptRole3;
title = supportbot.DepartmentTitle_3;
}
await ticketChannel.permissionOverwrites.edit(role.id, { await ticketChannel.permissionOverwrites.edit(role.id, {
VIEW_CHANNEL: true, VIEW_CHANNEL: true,
@@ -327,7 +293,37 @@ module.exports = new Command({
}); });
} catch (error) {} } catch (error) {}
} else { } else {
await ticketChannel.send({ embeds: [TicketMessage], components: [row2] }); await ticketChannel.send({
embeds: [TicketMessage],
components: [row2],
});
if (department) {
let role = await getRole(
supportbot.Departments[department].role,
interaction.guild
);
let title = supportbot.Departments[department].title;
await ticketChannel.permissionOverwrites.edit(role.id, {
VIEW_CHANNEL: true,
});
let TicketCat = await getCategory(
supportbot.Departments[department].category ||
supportbot.TicketCategory,
interaction.guild
);
await ticketChannel.setParent(TicketCat.id);
await ticketChannel.send({
embeds: [
{
description: `> Thank for reaching out to the **${title} Department**. Please provide us information regarding your query.`,
color: supportbot.EmbedColour,
},
],
});
}
if (supportbot.AllowTicketMentions) {
await ticketChannel.send("@here");
}
} }
}, },
}); });
+20 -22
View File
@@ -84,7 +84,7 @@ SuggestionDownvote: "❌"
# Tickets Configuration # Tickets Configuration
# ------------------------- # -------------------------
TicketCategory: "Tickets" TicketCategory: "Tickets" # Only for tickets without a category
TicketPrefix: "ticket-" # The prefix for ticket channel names TicketPrefix: "ticket-" # The prefix for ticket channel names
TicketLog: "logs" TicketLog: "logs"
@@ -143,14 +143,6 @@ TicketCloseColour: "DANGER"
TicketDeleteColour: "DANGER" TicketDeleteColour: "DANGER"
TicketLockColour: "PRIMARY" TicketLockColour: "PRIMARY"
TicketDept1Colour: "PRIMARY"
TicketDept2Colour: "PRIMARY"
TicketDept3Colour: "PRIMARY"
TicketDept1Emoji: "1️⃣"
TicketDept2Emoji: "2️⃣"
TicketDept3Emoji: "3️⃣"
TranscriptSavedMessage: "📝 **Transcript Saved!**" TranscriptSavedMessage: "📝 **Transcript Saved!**"
TicketLockMessage: "❌ **Ticket Locked!**" TicketLockMessage: "❌ **Ticket Locked!**"
TicketDeleteMessage: "⚠ **Ticket Deleting!**" # Tickets deleting after 5 seconds by default. TicketDeleteMessage: "⚠ **Ticket Deleting!**" # Tickets deleting after 5 seconds by default.
@@ -161,22 +153,28 @@ TicketDeleteMessage: "⚠ **Ticket Deleting!**" # Tickets deleting after 5 secon
TicketDepartments: true TicketDepartments: true
# Delete the ticket if no department selected. TIME IN MINUTES # Delete the ticket if no department selected. TIME IN MINUTES
Timeout: 5 Timeout: 5
AllowStaff: true # Set to true to allow all staff to access the ticket
# If set to false users with the "Staff" role will not be able to view tickets AllowAllStaff: false
# without a valid department role set below.
# Set to false to allow "Staff" to see tickets whether its a department for them or not.
DepartmentTitle_1: "General Support"
DepartmentTitle_2: "Billing Support"
DepartmentTitle_3: "Admin Team"
# Ticket department title, This is the title for a ticket department to help users know what is available.
DepartmentRole_1: "Support"
DepartmentRole_2: "Support"
DepartmentRole_3: "Admin"
# Ticket roles are the roles that will be able to gain access to tickets depending on what department has been chosen. # Ticket roles are the roles that will be able to gain access to tickets depending on what department has been chosen.
Departments:
- title: "General Support"
role: "Support"
color: "PRIMARY"
emoji: "1️⃣"
category: "Tickets"
- title: "Billing Support"
role: "Support"
color: "PRIMARY"
emoji: "2️⃣"
category: "Billing"
- title: "Admin Team"
role: "Admin"
color: "PRIMARY"
emoji: "3️⃣"
category: "Tickets"
# --- Closing Config --- # --- Closing Config ---
# --- Start --- # --- Start ---
+26 -15
View File
@@ -39,10 +39,12 @@ module.exports = new Event("ready", async (client) => {
`Connected to Discord` `Connected to Discord`
); );
console.log( console.log(
`\u001b[33m`, `\u001b[33m`,
`Invite to your server:`, `Invite to your server:`,
`\u001b[36m`, `\u001b[36m`,
`https://discord.com/api/oauth2/authorize?client_id=` + client.user.id + `&permissions=8&scope=bot%20applications.commands` `https://discord.com/api/oauth2/authorize?client_id=` +
client.user.id +
`&permissions=8&scope=bot%20applications.commands`
); );
console.log( console.log(
`\u001b[33m`, `\u001b[33m`,
@@ -88,10 +90,10 @@ module.exports = new Event("ready", async (client) => {
supportbot.Admin, supportbot.Admin,
supportbot.Staff, supportbot.Staff,
supportbot.TicketBlackListRole, supportbot.TicketBlackListRole,
supportbot.DepartmentRole_1,
supportbot.DepartmentRole_2,
supportbot.DepartmentRole_3,
]; ];
if (supportbot.TicketDepartments) {
supportbot.Departments.forEach((department) => roles.push(department.role));
}
if (supportbot.AutoRole) roles.push(supportbot.AutoRole_Role); if (supportbot.AutoRole) roles.push(supportbot.AutoRole_Role);
const channels = [ const channels = [
supportbot.SuggestionChannel, supportbot.SuggestionChannel,
@@ -160,7 +162,7 @@ module.exports = new Event("ready", async (client) => {
fs.readFileSync("./Data/ticket-panel-id.json", "utf8") fs.readFileSync("./Data/ticket-panel-id.json", "utf8")
); );
chan1.messages.fetch(panelid.TicketPanelID).catch(async (r) => { chan1.messages.fetch(panelid.TicketPanelID).catch(async () => {
let embed = new Discord.MessageEmbed() let embed = new Discord.MessageEmbed()
.setTitle(`${panelconfig.PanelTitle}`) .setTitle(`${panelconfig.PanelTitle}`)
.setColor(supportbot.SuccessColour) .setColor(supportbot.SuccessColour)
@@ -177,13 +179,22 @@ module.exports = new Event("ready", async (client) => {
if (panelconfig.TicketPanel_Image) { if (panelconfig.TicketPanel_Image) {
embed.setImage(panelconfig.PanelImage); embed.setImage(panelconfig.PanelImage);
} }
let button;
let button = new Discord.MessageButton() if (supportbot.TicketDepartments) {
.setLabel(panelconfig.ButtonLabel) button = supportbot.Departments.map((x) =>
.setCustomId("openticket") new Discord.MessageButton()
.setStyle(panelconfig.ButtonColour) .setCustomId("department-" + supportbot.Departments.indexOf(x))
.setEmoji(panelconfig.ButtonEmoji); .setLabel(x.title)
.setStyle(x.color)
.setEmoji(x.emoji)
);
} else {
button = new Discord.MessageButton()
.setLabel(panelconfig.ButtonLabel)
.setCustomId("openticket")
.setStyle(panelconfig.ButtonColour)
.setEmoji(panelconfig.ButtonEmoji);
}
let row = new Discord.MessageActionRow().addComponents(button); let row = new Discord.MessageActionRow().addComponents(button);
await chan1 await chan1