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"],
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(
fs.readFileSync("./Data/TicketData.json", "utf8")
);
@@ -73,8 +80,7 @@ module.exports = new Command({
const TicketExists = new MessageEmbed()
.setTitle("Ticket Exists!")
.setDescription(`${supportbot.TicketExists}`)
.setColor(supportbot.WarningColour);
.setDescription(`${supportbot.TicketExists}`);
if (
await interaction.guild.channels.cache.find(
@@ -89,19 +95,7 @@ module.exports = new Command({
}
const Staff = await getRole(supportbot.Staff, interaction.guild);
const Admin = await getRole(supportbot.Admin, interaction.guild);
const DeptRole1 = await getRole(
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)
if (!Staff || !Admin)
return interaction.reply({
content:
"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;
let TicketCategory = await getCategory(
supportbot.TicketCategory,
supportbot.Departments[department].category || supportbot.TicketCategory,
interaction.guild
);
const ticketChannel = await interaction.guild.channels.create(
@@ -133,13 +127,13 @@ module.exports = new Command({
],
}
);
if (supportbot.AllowStaff) {
ticketChannel.permissionOverwrites.edit(Staff.id, {
if (supportbot.AllowAllStaff) {
await ticketChannel.permissionOverwrites.edit(Staff.id, {
VIEW_CHANNEL: true,
});
}
if (supportbot.TicketDepartments) {
ticketChannel.permissionOverwrites.edit(interaction.user.id, {
if (supportbot.TicketDepartments && !department) {
await ticketChannel.permissionOverwrites.edit(interaction.user.id, {
SEND_MESSAGES: false,
});
}
@@ -203,10 +197,10 @@ module.exports = new Command({
}
}
if (supportbot.TicketDepartments) {
if (supportbot.TicketDepartments && !department) {
TicketMessage.addFields({
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()
@@ -222,33 +216,16 @@ module.exports = new Command({
.setEmoji(supportbot.TicketLockEmoji);
const row2 = new MessageActionRow().addComponents(CloseButton, LockButton);
if (supportbot.TicketDepartments) {
if (supportbot.TicketDepartments && !department) {
try {
const Department1Button = new MessageButton()
.setCustomId("Department1")
.setLabel(supportbot.DepartmentTitle_1)
.setStyle(supportbot.TicketDept1Colour)
.setEmoji(supportbot.TicketDept1Emoji);
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
let buttons = await supportbot.Departments.map((x) =>
new MessageButton()
.setCustomId("Department" + supportbot.Departments.indexOf(x))
.setLabel(x.title)
.setStyle(x.color)
.setEmoji(x.emoji)
);
const row = new MessageActionRow().addComponents(buttons);
const m = await ticketChannel.send({
embeds: [TicketMessage],
components: [row],
@@ -287,20 +264,9 @@ module.exports = new Command({
return await ticketChannel.delete();
}
}
let role;
let title;
if (collector.customId === "Department1") {
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;
}
let num = collector.customId.split("Department")[1];
let role = getRole(supportbot.Departments[num].role, interaction.guild);
let title = supportbot.Departments[num].title;
await ticketChannel.permissionOverwrites.edit(role.id, {
VIEW_CHANNEL: true,
@@ -327,7 +293,37 @@ module.exports = new Command({
});
} catch (error) {}
} 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");
}
}
},
});