Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,17 @@ module.exports = {
} catch (error) {
error.errorContext = `[InteractionCreate]: an error occurred while executing the ${command.data.name} command.`;
client.emit("error", error);
await interaction.editReply({
const commandErrorReply = {
content:
config.errors.command_error ||
"There was an error while executing this command!",
flags: MessageFlags.Ephemeral,
});
};
if (interaction.deferred || interaction.replied) {
await interaction.editReply(commandErrorReply);
} else {
await interaction.reply(commandErrorReply);
}
}
} else if (interaction.isStringSelectMenu()) {
if (interaction.customId === "categoryMenu") {
Expand Down
5 changes: 4 additions & 1 deletion utils/mainUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ async function logMessage(message) {

async function checkSupportRole(interaction) {
const foundId = await ticketsDB.get(`${interaction.channel.id}.button`);
const allowedRoles = ticketCategories[foundId].support_role_ids;
const allowedRoles = ticketCategories[foundId]?.support_role_ids;
if (!allowedRoles) {
return false;
}
return interaction.member.roles.cache.some((role) =>
allowedRoles.includes(role.id),
);
Expand Down
17 changes: 14 additions & 3 deletions utils/ticketClose.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,24 @@ const {
} = require("./mainUtils.js");

async function closeTicket(interaction, reason = "No reason provided.") {
const ticketCreatorID = await ticketsDB.get(
`${interaction.channel.id}.userID`,
);
const ticketUserID = ticketCreatorID ? await getUser(ticketCreatorID) : null;
if (!ticketUserID) {
await logMessage(
`Could not close the ticket in channel ${interaction.channel.id}: its database entry has no creator, or the creator could not be fetched.`,
);
await interaction.editReply({
content:
"The ticket data for this channel is missing, so it cannot be closed. Delete the channel manually instead.",
});
return;
}
await ticketsDB.set(
`${interaction.channel.id}.closeUserID`,
interaction.user.id,
);
const ticketUserID = await getUser(
await ticketsDB.get(`${interaction.channel.id}.userID`),
);
const claimUserID = await ticketsDB.get(
`${interaction.channel.id}.claimUser`,
);
Expand Down