Possibly fix /close?
This commit is contained in:
1 parent
d4d96f59ab
commit
6b01d0c8fe
2 files changed
+118
-110
No files matched your search
+14
-15
@@ -25,6 +25,7 @@ module.exports = new Command({
|
|||||||
permission: "SEND_MESSAGES",
|
permission: "SEND_MESSAGES",
|
||||||
|
|
||||||
async run(interaction) {
|
async run(interaction) {
|
||||||
|
await interaction.deferReply();
|
||||||
let TicketData = await JSON.parse(
|
let TicketData = await JSON.parse(
|
||||||
fs.readFileSync("./Data/TicketData.json", "utf8")
|
fs.readFileSync("./Data/TicketData.json", "utf8")
|
||||||
).tickets.find((t) => t.id === interaction.channel.id);
|
).tickets.find((t) => t.id === interaction.channel.id);
|
||||||
@@ -36,7 +37,7 @@ module.exports = new Command({
|
|||||||
.setTitle("No Ticket Found!")
|
.setTitle("No Ticket Found!")
|
||||||
.setDescription(`${supportbot.NoValidTicket}`)
|
.setDescription(`${supportbot.NoValidTicket}`)
|
||||||
.setColor(supportbot.WarningColour);
|
.setColor(supportbot.WarningColour);
|
||||||
return interaction.reply({ embeds: [Exists] });
|
return interaction.followUp({ embeds: [Exists] });
|
||||||
}
|
}
|
||||||
let tUser = interaction.client.users.cache.get(TicketData.user);
|
let tUser = interaction.client.users.cache.get(TicketData.user);
|
||||||
let transcriptChannel = await interaction.guild.channels.cache.find(
|
let transcriptChannel = await interaction.guild.channels.cache.find(
|
||||||
@@ -53,7 +54,7 @@ module.exports = new Command({
|
|||||||
(await interaction.options?.getString("reason")) || "No Reason Provided.";
|
(await interaction.options?.getString("reason")) || "No Reason Provided.";
|
||||||
|
|
||||||
if (!transcriptChannel || !logChannel)
|
if (!transcriptChannel || !logChannel)
|
||||||
return interaction.reply("Some Channels seem to be missing!");
|
return interaction.followUp("Some Channels seem to be missing!");
|
||||||
if (supportbot.CloseConfirmation) {
|
if (supportbot.CloseConfirmation) {
|
||||||
const CloseTicketRequest = new Discord.MessageEmbed()
|
const CloseTicketRequest = new Discord.MessageEmbed()
|
||||||
.setTitle(`**${supportbot.ClosingTicket}**`)
|
.setTitle(`**${supportbot.ClosingTicket}**`)
|
||||||
@@ -61,21 +62,19 @@ module.exports = new Command({
|
|||||||
`Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` `
|
`Please confirm by repeating the following word.. \`${supportbot.ClosingConfirmation_Word}\` `
|
||||||
)
|
)
|
||||||
.setColor(supportbot.EmbedColour);
|
.setColor(supportbot.EmbedColour);
|
||||||
|
await interaction.followUp({ embeds: [CloseTicketRequest] });
|
||||||
await interaction.reply({ embeds: [CloseTicketRequest] });
|
let filter = (m) =>
|
||||||
await interaction.channel.awaitMessages(
|
m.content.toLowerCase() == supportbot.ClosingConfirmation_Word &&
|
||||||
(r) =>
|
m.author.id == interaction.user.id;
|
||||||
r.content.toLowerCase() === supportbot.ClosingConfirmation_Word &&
|
await interaction.channel.awaitMessages({
|
||||||
r.author.id === interaction.author.id,
|
filter,
|
||||||
{
|
max: 1,
|
||||||
max: 1,
|
time: 20000,
|
||||||
time: 20000,
|
errors: ["time"],
|
||||||
errors: ["time"],
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await interaction.reply(`**${supportbot.ClosingTicket}**`);
|
await interaction.followUp(`**${supportbot.ClosingTicket}**`);
|
||||||
const transcriptEmbed = new Discord.MessageEmbed()
|
const transcriptEmbed = new Discord.MessageEmbed()
|
||||||
.setTitle(supportbot.TranscriptTitle)
|
.setTitle(supportbot.TranscriptTitle)
|
||||||
.setColor(supportbot.EmbedColour)
|
.setColor(supportbot.EmbedColour)
|
||||||
|
|||||||
+104
-95
@@ -71,7 +71,7 @@ module.exports = new Command({
|
|||||||
ticketChannel.name === `${supportbot.TicketPrefix}${ticketNumberID}`;
|
ticketChannel.name === `${supportbot.TicketPrefix}${ticketNumberID}`;
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
return interaction.reply({ embeds: [TicketExists] });
|
return await interaction.reply({ embeds: [TicketExists] });
|
||||||
}
|
}
|
||||||
const Staff = interaction.guild.roles.cache.find(
|
const Staff = interaction.guild.roles.cache.find(
|
||||||
(SupportTeam) =>
|
(SupportTeam) =>
|
||||||
@@ -140,7 +140,7 @@ module.exports = new Command({
|
|||||||
.replace(/%ticketusername%/g, interaction.user.username)
|
.replace(/%ticketusername%/g, interaction.user.username)
|
||||||
)
|
)
|
||||||
.setColor(supportbot.EmbedColour);
|
.setColor(supportbot.EmbedColour);
|
||||||
interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
|
await interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
|
||||||
} else {
|
} else {
|
||||||
const CreatedTicket = new Discord.MessageEmbed()
|
const CreatedTicket = new Discord.MessageEmbed()
|
||||||
.setDescription(
|
.setDescription(
|
||||||
@@ -152,16 +152,20 @@ module.exports = new Command({
|
|||||||
.replace(/%ticketusername%/g, interaction.user.username)
|
.replace(/%ticketusername%/g, interaction.user.username)
|
||||||
)
|
)
|
||||||
.setColor(supportbot.EmbedColour);
|
.setColor(supportbot.EmbedColour);
|
||||||
interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
|
await interaction.reply({ embeds: [CreatedTicket], ephemeral: true });
|
||||||
}
|
}
|
||||||
let AllowArr = [Staff, Staff, Admins, Author];
|
let AllowArr = [Staff, Staff, Admins, Author];
|
||||||
await asyncForEach(AllowArr, (index) => {
|
await asyncForEach(AllowArr, async (index) => {
|
||||||
ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: true });
|
await ticketChannel.permissionOverwrites.create(index, {
|
||||||
|
VIEW_CHANNEL: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let DenyArr = [Everyone];
|
let DenyArr = [Everyone];
|
||||||
await asyncForEach(DenyArr, (index) => {
|
await asyncForEach(DenyArr, async (index) => {
|
||||||
ticketChannel.permissionOverwrites.create(index, { VIEW_CHANNEL: false });
|
await ticketChannel.permissionOverwrites.create(index, {
|
||||||
|
VIEW_CHANNEL: false,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let TicketCategory = interaction.guild.channels.cache.find(
|
let TicketCategory = interaction.guild.channels.cache.find(
|
||||||
@@ -170,11 +174,11 @@ module.exports = new Command({
|
|||||||
category.id === supportbot.TicketCategory
|
category.id === supportbot.TicketCategory
|
||||||
);
|
);
|
||||||
if (TicketCategory) {
|
if (TicketCategory) {
|
||||||
ticketChannel.setParent(TicketCategory.id);
|
await ticketChannel.setParent(TicketCategory.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportbot.AllowTicketMentions) {
|
if (supportbot.AllowTicketMentions) {
|
||||||
ticketChannel.send({ content: `${interaction.user}` });
|
await ticketChannel.send({ content: `${interaction.user}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
const TicketMessage = new Discord.MessageEmbed()
|
const TicketMessage = new Discord.MessageEmbed()
|
||||||
@@ -198,7 +202,7 @@ module.exports = new Command({
|
|||||||
|
|
||||||
if (supportbot.TicketSubject === "description") {
|
if (supportbot.TicketSubject === "description") {
|
||||||
if (TicketSubject != "No Reason Provided.") {
|
if (TicketSubject != "No Reason Provided.") {
|
||||||
ticketChannel.setTopic(
|
await ticketChannel.setTopic(
|
||||||
`Reason: ${TicketSubject} - User ID: ${interaction.user.id} - Ticket: ${ticketChannel.name}`
|
`Reason: ${TicketSubject} - User ID: ${interaction.user.id} - Ticket: ${ticketChannel.name}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -263,104 +267,109 @@ module.exports = new Command({
|
|||||||
components: [row],
|
components: [row],
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = (i) => {
|
const filter = (i) => i.user.id === interaction.user.id;
|
||||||
i.deferUpdate();
|
const collector = await m.awaitMessageComponent({
|
||||||
return i.user.id === interaction.user.id;
|
|
||||||
};
|
|
||||||
const collector = m.createMessageComponentCollector({
|
|
||||||
filter,
|
filter,
|
||||||
max: 1,
|
max: 1,
|
||||||
componentType: "BUTTON",
|
componentType: "BUTTON",
|
||||||
time: 60000,
|
time: 60000,
|
||||||
});
|
});
|
||||||
|
await collector.deferUpdate();
|
||||||
|
|
||||||
collector.on("collect", async (i) => {
|
if (collector.customId === "Department1") {
|
||||||
if (i.customId === "Department1") {
|
await ticketChannel.permissionOverwrites.edit(DeptRole1, {
|
||||||
ticketChannel.permissionOverwrites.edit(DeptRole1, {
|
VIEW_CHANNEL: true,
|
||||||
VIEW_CHANNEL: true,
|
READ_MESSAGE_HISTORY: true,
|
||||||
READ_MESSAGE_HISTORY: true,
|
SEND_MESSAGES: true,
|
||||||
SEND_MESSAGES: true,
|
});
|
||||||
|
|
||||||
|
if (!supportbot.AllowStaff) {
|
||||||
|
await ticketChannel.permissionOverwrites.edit(Staff, {
|
||||||
|
VIEW_CHANNEL: false,
|
||||||
|
READ_MESSAGE_HISTORY: false,
|
||||||
|
SEND_MESSAGES: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!supportbot.AllowStaff) {
|
|
||||||
ticketChannel.permissionOverwrites.edit(Staff, {
|
|
||||||
VIEW_CHANNEL: false,
|
|
||||||
READ_MESSAGE_HISTORY: false,
|
|
||||||
SEND_MESSAGES: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const Department1 = new Discord.MessageEmbed()
|
|
||||||
.setDescription(
|
|
||||||
`> Thank for reaching out to the **${supportbot.DepartmentTitle_1} Department**. Please provide us information regarding your query.`
|
|
||||||
)
|
|
||||||
.setColor(supportbot.EmbedColour);
|
|
||||||
ticketChannel.send({ embeds: [Department1] });
|
|
||||||
|
|
||||||
if (supportbot.AllowTicketMentions) {
|
|
||||||
ticketChannel.send({ content: `@here` });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
i.message.edit({ embeds: [TicketMessage], components: [row2] });
|
|
||||||
|
|
||||||
if (i.customId === "Department2") {
|
const Department1 = new Discord.MessageEmbed()
|
||||||
ticketChannel.permissionOverwrites.edit(DeptRole2, {
|
.setDescription(
|
||||||
VIEW_CHANNEL: true,
|
`> Thank for reaching out to the **${supportbot.DepartmentTitle_1} Department**. Please provide us information regarding your query.`
|
||||||
READ_MESSAGE_HISTORY: true,
|
)
|
||||||
SEND_MESSAGES: true,
|
.setColor(supportbot.EmbedColour);
|
||||||
});
|
await ticketChannel.send({ embeds: [Department1] });
|
||||||
|
|
||||||
if (!supportbot.AllowStaff) {
|
if (supportbot.AllowTicketMentions) {
|
||||||
ticketChannel.permissionOverwrites.edit(Staff, {
|
await ticketChannel.send({ content: `@here` });
|
||||||
VIEW_CHANNEL: false,
|
|
||||||
READ_MESSAGE_HISTORY: false,
|
|
||||||
SEND_MESSAGES: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const Department2 = new Discord.MessageEmbed()
|
|
||||||
.setDescription(
|
|
||||||
`> Thank for reaching out to the **${supportbot.DepartmentTitle_2} Department**. Please provide us information regarding your query.`
|
|
||||||
)
|
|
||||||
.setColor(supportbot.EmbedColour);
|
|
||||||
ticketChannel.send({ embeds: [Department2] });
|
|
||||||
|
|
||||||
if (supportbot.AllowTicketMentions) {
|
|
||||||
ticketChannel.send({ content: `@here` });
|
|
||||||
}
|
|
||||||
|
|
||||||
i.message.edit({ embeds: [TicketMessage], components: [row2] });
|
|
||||||
}
|
|
||||||
if (i.customId === "Department3") {
|
|
||||||
ticketChannel.permissionOverwrites.edit(DeptRole3, {
|
|
||||||
VIEW_CHANNEL: true,
|
|
||||||
READ_MESSAGE_HISTORY: true,
|
|
||||||
SEND_MESSAGES: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!supportbot.AllowStaff) {
|
|
||||||
ticketChannel.permissionOverwrites.edit(Staff, {
|
|
||||||
VIEW_CHANNEL: false,
|
|
||||||
READ_MESSAGE_HISTORY: false,
|
|
||||||
SEND_MESSAGES: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const Department3 = new Discord.MessageEmbed()
|
|
||||||
.setDescription(
|
|
||||||
`> Thank for reaching out to the **${supportbot.DepartmentTitle_3} Department**. Please provide us information regarding your query.`
|
|
||||||
)
|
|
||||||
.setColor(supportbot.EmbedColour);
|
|
||||||
ticketChannel.send({ embeds: [Department3] });
|
|
||||||
|
|
||||||
if (supportbot.AllowTicketMentions) {
|
|
||||||
ticketChannel.send({ content: `@here` });
|
|
||||||
}
|
|
||||||
i.message.edit({ embeds: [TicketMessage], components: [row2] });
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
await collector.message.edit({
|
||||||
|
embeds: [TicketMessage],
|
||||||
|
components: [row2],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (collector.customId === "Department2") {
|
||||||
|
await ticketChannel.permissionOverwrites.edit(DeptRole2, {
|
||||||
|
VIEW_CHANNEL: true,
|
||||||
|
READ_MESSAGE_HISTORY: true,
|
||||||
|
SEND_MESSAGES: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!supportbot.AllowStaff) {
|
||||||
|
await ticketChannel.permissionOverwrites.edit(Staff, {
|
||||||
|
VIEW_CHANNEL: false,
|
||||||
|
READ_MESSAGE_HISTORY: false,
|
||||||
|
SEND_MESSAGES: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const Department2 = new Discord.MessageEmbed()
|
||||||
|
.setDescription(
|
||||||
|
`> Thank for reaching out to the **${supportbot.DepartmentTitle_2} Department**. Please provide us information regarding your query.`
|
||||||
|
)
|
||||||
|
.setColor(supportbot.EmbedColour);
|
||||||
|
await ticketChannel.send({ embeds: [Department2] });
|
||||||
|
|
||||||
|
if (supportbot.AllowTicketMentions) {
|
||||||
|
await ticketChannel.send({ content: `@here` });
|
||||||
|
}
|
||||||
|
|
||||||
|
await collector.message.edit({
|
||||||
|
embeds: [TicketMessage],
|
||||||
|
components: [row2],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (collector.customId === "Department3") {
|
||||||
|
await ticketChannel.permissionOverwrites.edit(DeptRole3, {
|
||||||
|
VIEW_CHANNEL: true,
|
||||||
|
READ_MESSAGE_HISTORY: true,
|
||||||
|
SEND_MESSAGES: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!supportbot.AllowStaff) {
|
||||||
|
await ticketChannel.permissionOverwrites.edit(Staff, {
|
||||||
|
VIEW_CHANNEL: false,
|
||||||
|
READ_MESSAGE_HISTORY: false,
|
||||||
|
SEND_MESSAGES: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const Department3 = new Discord.MessageEmbed()
|
||||||
|
.setDescription(
|
||||||
|
`> Thank for reaching out to the **${supportbot.DepartmentTitle_3} Department**. Please provide us information regarding your query.`
|
||||||
|
)
|
||||||
|
.setColor(supportbot.EmbedColour);
|
||||||
|
await ticketChannel.send({ embeds: [Department3] });
|
||||||
|
|
||||||
|
if (supportbot.AllowTicketMentions) {
|
||||||
|
await ticketChannel.send({ content: `@here` });
|
||||||
|
}
|
||||||
|
await collector.message.edit({
|
||||||
|
embeds: [TicketMessage],
|
||||||
|
components: [row2],
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ticketChannel.send({ embeds: [TicketMessage], components: [row2] });
|
await ticketChannel.send({ embeds: [TicketMessage], components: [row2] });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user