diff --git a/src/commands/alias.ts b/src/commands/alias.ts index 660dadb..9887233 100644 --- a/src/commands/alias.ts +++ b/src/commands/alias.ts @@ -1,6 +1,7 @@ import { Embed, SlashCommandBuilder } from "@discordjs/builders"; import { Command } from "../Command"; import { checkManager } from "../utils/conditions"; +import { logger } from "../utils/logger"; import { deleteAlias, listAliases, @@ -69,12 +70,22 @@ export const alias: Command = { case "list": const aliases = await listAliases(interaction.guildId); - const numsPerGroup = Math.ceil(aliases.length / 25); - const results = new Array().map((_, i) => - aliases.slice(i * numsPerGroup, (i + 1) * numsPerGroup) - ); - const embeds = results.map((result) => - new Embed().addFields(...result).setTitle("Alias List") + const chunk = (arr, size) => { + const res = []; + for(let i = 0; i < arr.length; i++) { + if(i % size === 0){ + // Push a new array containing the current value to the res array + res.push([arr[i]]); + } + else{ + // Push the current value to the current array + res[res.length-1].push(arr[i]); + }; + }; + return res; + }; + const embeds = chunk(aliases, 25).map((result) => + new Embed().addFields(...result) ); interaction.reply({ content: `Alias List`,