Skip to content

Commit

Permalink
Fix potential crash when listing tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Feb 6, 2024
1 parent c143ada commit 5e2fe09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ export const run: SlashSubcommand<true>["run"] = async (_, interaction) => {

const onPageChange: OnButtonPageChange = async (_, page) => {
const tickets = ticketArray.slice(
ticketsPerPage * (page - 1),
ticketsPerPage * page,
ticketsPerPage * (page + 1),
);

for (let i = 0; i < tickets.length; ++i) {
const ticket = tickets[i];

embed.addFields({
name: `${ticketsPerPage * page + i + 1}. ${ticket.title}`,
name: `${ticketsPerPage * (page - 1) + i + 1}. ${ticket.title}`,
value: `${localization.getTranslation("ticketStatus")}: ${ticket.statusToString()} | ${hyperlink(localization.getTranslation("ticketGoToChannel"), ticket.threadChannelURL)}`,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ export const run: SlashSubcommand<true>["run"] = async (_, interaction) => {

const onPageChange: OnButtonPageChange = async (_, page) => {
const tickets = ticketArray.slice(
ticketsPerPage * (page - 1),
ticketsPerPage * page,
ticketsPerPage * (page + 1),
);

for (let i = 0; i < tickets.length; ++i) {
const ticket = tickets[i];

embed.addFields({
name: `${ticketsPerPage * page + i + 1}. ${ticket.title}`,
name: `${ticketsPerPage * (page - 1) + i + 1}. ${ticket.title}`,
value: `${localization.getTranslation("ticketStatus")}: ${ticket.statusToString()} | ${hyperlink(localization.getTranslation("ticketGoToChannel"), ticket.threadChannelURL)}`,
});
}
Expand Down

0 comments on commit 5e2fe09

Please sign in to comment.