Added Max Ticket Count + Timeout
This commit is contained in:
1 parent
1178a0a611
commit
33f7675aac
3 files changed
+65
-16
No files matched your search
+12
-1
@@ -47,9 +47,12 @@ module.exports = new Command({
|
|||||||
return interaction.reply({ embeds: [NoPerms] });
|
return interaction.reply({ embeds: [NoPerms] });
|
||||||
}
|
}
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
let TicketData = await JSON.parse(
|
let tickets = 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);
|
||||||
|
let TicketData = await tickets.tickets.findIndex(
|
||||||
|
(t) => t.id == ticketChannel.id
|
||||||
|
);
|
||||||
if (!TicketData) {
|
if (!TicketData) {
|
||||||
const Exists = new Discord.MessageEmbed()
|
const Exists = new Discord.MessageEmbed()
|
||||||
.setTitle("No Ticket Found!")
|
.setTitle("No Ticket Found!")
|
||||||
@@ -87,6 +90,14 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
tickets.tickets[TicketData].open = false;
|
||||||
|
fs.writeFileSync(
|
||||||
|
"./Data/TicketData.json",
|
||||||
|
JSON.stringify(tickets, null, 4),
|
||||||
|
(err) => {
|
||||||
|
if (err) console.error(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
await interaction.followUp(`**${supportbot.ClosingTicket}**`);
|
await interaction.followUp(`**${supportbot.ClosingTicket}**`);
|
||||||
const transcriptEmbed = new Discord.MessageEmbed()
|
const transcriptEmbed = new Discord.MessageEmbed()
|
||||||
.setTitle(supportbot.TranscriptTitle)
|
.setTitle(supportbot.TranscriptTitle)
|
||||||
|
|||||||
+49
-12
@@ -31,11 +31,29 @@ module.exports = new Command({
|
|||||||
permissions: ["SEND_MESSAGES"],
|
permissions: ["SEND_MESSAGES"],
|
||||||
|
|
||||||
async run(interaction) {
|
async run(interaction) {
|
||||||
|
let TicketData = await JSON.parse(
|
||||||
|
fs.readFileSync("./Data/TicketData.json", "utf8")
|
||||||
|
);
|
||||||
const { getRole, getChannel, getCategory } = interaction.client;
|
const { getRole, getChannel, getCategory } = interaction.client;
|
||||||
let reactionUser = interaction.guild.members.cache.get(interaction.user.id);
|
let User = interaction.guild.members.cache.get(interaction.user.id);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
reactionUser.roles.cache.has(
|
supportbot.MaxAllowedTickets &&
|
||||||
|
TicketData.tickets.filter((t) => t.user == interaction.user.id && t.open)
|
||||||
|
.length >= supportbot.MaxAllowedTickets
|
||||||
|
) {
|
||||||
|
return interaction.reply({
|
||||||
|
embeds: [
|
||||||
|
{
|
||||||
|
title: "Too Many Tickets!",
|
||||||
|
description: `You can't have more than ${supportbot.MaxAllowedTickets} open tickets!`,
|
||||||
|
color: supportbot.WarningColour,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
User.roles.cache.has(
|
||||||
getRole(supportbot.TicketBlackListRole, interaction.guild).id
|
getRole(supportbot.TicketBlackListRole, interaction.guild).id
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -49,10 +67,6 @@ module.exports = new Command({
|
|||||||
// Ticket ID
|
// Ticket ID
|
||||||
let ticketNumberID = await TicketNumberID.pad();
|
let ticketNumberID = await TicketNumberID.pad();
|
||||||
|
|
||||||
let TicketData = await JSON.parse(
|
|
||||||
fs.readFileSync("./Data/TicketData.json", "utf8")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Ticket Subject
|
// Ticket Subject
|
||||||
const TicketSubject =
|
const TicketSubject =
|
||||||
interaction.options?.getString("reason") || supportbot.NoTicketSubject;
|
interaction.options?.getString("reason") || supportbot.NoTicketSubject;
|
||||||
@@ -127,6 +141,7 @@ module.exports = new Command({
|
|||||||
user: Author.id,
|
user: Author.id,
|
||||||
number: ticketNumberID,
|
number: ticketNumberID,
|
||||||
reason: TicketSubject,
|
reason: TicketSubject,
|
||||||
|
open: true,
|
||||||
subUsers: [],
|
subUsers: [],
|
||||||
});
|
});
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
@@ -232,12 +247,34 @@ module.exports = new Command({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const filter = (i) => i.user.id === interaction.user.id;
|
const filter = (i) => i.user.id === interaction.user.id;
|
||||||
const collector = await m.awaitMessageComponent({
|
let collector;
|
||||||
filter,
|
try {
|
||||||
max: 1,
|
collector = await m.awaitMessageComponent({
|
||||||
componentType: "BUTTON",
|
filter,
|
||||||
time: 60000,
|
max: 1,
|
||||||
});
|
componentType: "BUTTON",
|
||||||
|
time: supportbot.Timeout * 60000,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code == "INTERACTION_COLLECTOR_ERROR")
|
||||||
|
try {
|
||||||
|
let ticket = await TicketData.tickets.findIndex(
|
||||||
|
(t) => t.id == ticketChannel.id
|
||||||
|
);
|
||||||
|
TicketData.tickets[ticket].open = false;
|
||||||
|
fs.writeFileSync(
|
||||||
|
"./Data/TicketData.json",
|
||||||
|
JSON.stringify(TicketData, null, 4),
|
||||||
|
(err) => {
|
||||||
|
if (err) console.error(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
interaction.user.send(
|
||||||
|
"Your ticket has timed out. Please open a new one, and select a department."
|
||||||
|
);
|
||||||
|
} catch (e) {}
|
||||||
|
return await ticketChannel.delete();
|
||||||
|
}
|
||||||
let role;
|
let role;
|
||||||
let title;
|
let title;
|
||||||
if (collector.customId === "Department1") {
|
if (collector.customId === "Department1") {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ SupportBot_Version: "7.4.0"
|
|||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
||||||
Name: "SupportBot"
|
Name: "SupportBot"
|
||||||
# No Prefix, as everything uses the new Slash (/) Commands feature!
|
|
||||||
Token: "BOT_TOKEN"
|
Token: "BOT_TOKEN"
|
||||||
# Guild ID Ex: 123456789123456789
|
# Guild ID Ex: 123456789123456789
|
||||||
Guild: ""
|
Guild: ""
|
||||||
@@ -95,6 +94,8 @@ TranscriptTitle: "Ticket Transcript"
|
|||||||
TicketLog_Title: "Ticket Closed"
|
TicketLog_Title: "Ticket Closed"
|
||||||
TicketBlackListMessage: "You are not allowed to open a ticket"
|
TicketBlackListMessage: "You are not allowed to open a ticket"
|
||||||
|
|
||||||
|
MaxAllowedTickets: 2
|
||||||
|
|
||||||
TicketSubject: "description"
|
TicketSubject: "description"
|
||||||
# "description" will displays the ticket reason within the channel description
|
# "description" will displays the ticket reason within the channel description
|
||||||
# "embed" will displays the ticket reason within the ticket embed
|
# "embed" will displays the ticket reason within the ticket embed
|
||||||
@@ -153,13 +154,13 @@ 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.
|
||||||
TicketDeleteTime: 5000 # Time must be set in milliseconds.
|
|
||||||
|
|
||||||
# --- Departments Config ---
|
# --- Departments Config ---
|
||||||
# --- Start ---
|
# --- Start ---
|
||||||
|
|
||||||
TicketDepartments: true
|
TicketDepartments: true
|
||||||
|
# Delete the ticket if no department selected. TIME IN MINUTES
|
||||||
|
Timeout: 5
|
||||||
AllowStaff: true
|
AllowStaff: true
|
||||||
# If set to false users with the "Staff" role will not be able to view tickets
|
# If set to false users with the "Staff" role will not be able to view tickets
|
||||||
# without a valid department role set below.
|
# without a valid department role set below.
|
||||||
|
|||||||
Reference in new issue
Block a user