Okay so, I downloaded an old plugin that works on discord.js V12 (discord-pagination) and I want it to work on V13 too, so what can I do?
When I'm trying to use my command it says Cannot send an empty message, the issue is in that code below.
const paginationEmbed = async (msg, pages, emojiList = ["⏪", "⏩"], timeout = 120000) => {
if (!msg && !msg.channel) throw new Error("Channel is inaccessible.");
if (!pages) throw new Error("Pages are not given.");
if (emojiList.length !== 2) throw new Error("Need two emojis.");
let page = 0;
const curPage = await msg.channel.send(pages[page].setFooter(`Page ${page + 1} / ${pages.length}`));
for (const emoji of emojiList) await curPage.react(emoji);
const reactionCollector = curPage.createReactionCollector((reaction, user) => emojiList.includes(reaction.emoji.name) && !user.bot, { time: timeout });
reactionCollector.on("collect", (reaction) => {
reaction.users.remove(msg.author);
switch (reaction.emoji.name) {
case emojiList[0]:
page = page > 0 ? --page : pages.length - 1;
break;
case emojiList[1]:
page = page + 1 < pages.length ? ++page : 0;
break;
default:
break;
}
curPage.edit(pages[page].setFooter(`Page ${page + 1} / ${pages.length}`));
});
reactionCollector.on("end", () => {
if (!curPage.deleted) {
curPage.reactions.removeAll();
}
});
return curPage;
};
module.exports = paginationEmbed;
Guessing from your code, I think the problem is sending an embed.
message.channel.send(embed) // deprecated
message.channel.send({embeds: [embed] }) // V13 version
So for you you would have to change one line:
// change this
const curPage = await msg.channel.send(pages[page].setFooter(`Page ${page + 1} / ${pages.length}`));
// to this
const curPage = await msg.channel.send({ embeds: [pages[page].setFooter(`Page ${page + 1} / ${pages.length}`)] });
Same goes for curPage.edit:
// change this
curPage.edit(pages[page].setFooter(`Page ${page + 1} / ${pages.length}`));
// to this
curPage.edit({ embeds: [pages[page].setFooter(`Page ${page + 1} / ${pages.length}`)] });
Also you might want to give the Guide a read, on how to update from V12 to V13