@aeroware/discord-utils
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -54,3 +54,4 @@ "use strict"; | ||
if (options.startingPage) { | ||
if (typeof options.startingPage !== "number" || !Number.isInteger(options.startingPage)) | ||
if (typeof options.startingPage !== "number" || | ||
!Number.isInteger(options.startingPage)) | ||
throw new Error("Starting page index must be an integer."); | ||
@@ -70,3 +71,3 @@ if (options.startingPage < 0) | ||
if (options.fastForwardAndRewind.time) { | ||
if (typeof options.time !== "number") | ||
if (typeof options.fastForwardAndRewind.time !== "number") | ||
throw new Error("Fast forward and rewind time must be a non-negative number."); | ||
@@ -77,7 +78,9 @@ if (options.fastForwardAndRewind.time < 0) | ||
if (options.fastForwardAndRewind.fastForwardPrompt) { | ||
if (typeof options.fastForwardAndRewind.fastForwardPrompt !== "string" || !options.fastForwardAndRewind.fastForwardPrompt.length) | ||
if (typeof options.fastForwardAndRewind.fastForwardPrompt !== "string" || | ||
!options.fastForwardAndRewind.fastForwardPrompt.length) | ||
throw new Error("Prompt should be a string that is not empty."); | ||
} | ||
if (options.fastForwardAndRewind.rewindPrompt) { | ||
if (typeof options.fastForwardAndRewind.rewindPrompt !== "string" || !options.fastForwardAndRewind.rewindPrompt.length) | ||
if (typeof options.fastForwardAndRewind.rewindPrompt !== "string" || | ||
!options.fastForwardAndRewind.rewindPrompt.length) | ||
throw new Error("Prompt should be a string that is not empty."); | ||
@@ -100,3 +103,4 @@ } | ||
pagination = _a.sent(); | ||
emojis = (options === null || options === void 0 ? void 0 : options.fastForwardAndRewind) ? ["⏪", "◀️", "⏹", "▶️", "⏩"] : ["◀️", "⏹", "▶️"]; | ||
emojis = (options === null || options === void 0 ? void 0 : options.fastForwardAndRewind) ? ["⏪", "◀️", "⏹", "▶️", "⏩"] | ||
: ["◀️", "⏹", "▶️"]; | ||
if (options === null || options === void 0 ? void 0 : options.goTo) | ||
@@ -109,3 +113,5 @@ emojis.push("🔢"); | ||
pagination.react(emojis[(options === null || options === void 0 ? void 0 : options.fastForwardAndRewind) ? 2 : 1]); | ||
collector = pagination.createReactionCollector(function (reaction, user) { return emojis.includes(reaction.emoji.name) && user.id === message.author.id; }, { | ||
collector = pagination.createReactionCollector(function (reaction, user) { | ||
return emojis.includes(reaction.emoji.name) && user.id === message.author.id; | ||
}, { | ||
dispose: true, | ||
@@ -135,3 +141,4 @@ time: (options === null || options === void 0 ? void 0 : options.time) || 60000, | ||
return [2 /*return*/]; | ||
return [4 /*yield*/, message.channel.send(options.fastForwardAndRewind.rewindPrompt || "How many pages would you like to go back?")]; | ||
return [4 /*yield*/, message.channel.send(options.fastForwardAndRewind.rewindPrompt || | ||
"How many pages would you like to go back?")]; | ||
case 2: | ||
@@ -178,3 +185,4 @@ rwp = _h.sent(); | ||
return [2 /*return*/]; | ||
return [4 /*yield*/, message.channel.send(options.fastForwardAndRewind.fastForwardPrompt || "How many pages would you like to go forward?")]; | ||
return [4 /*yield*/, message.channel.send(options.fastForwardAndRewind.fastForwardPrompt || | ||
"How many pages would you like to go forward?")]; | ||
case 11: | ||
@@ -181,0 +189,0 @@ ffp = _h.sent(); |
{ | ||
"name": "@aeroware/discord-utils", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -28,5 +28,11 @@ import { Message, MessageEmbed, MessageReaction, User } from "discord.js"; | ||
if (options.startingPage) { | ||
if (typeof options.startingPage !== "number" || !Number.isInteger(options.startingPage)) throw new Error("Starting page index must be an integer."); | ||
if (options.startingPage < 0) throw new Error("Starting page index must be non-negative or zero."); | ||
if (options.startingPage > pages.length - 1) throw new Error("Starting page index is greater than the length of the pages."); | ||
if ( | ||
typeof options.startingPage !== "number" || | ||
!Number.isInteger(options.startingPage) | ||
) | ||
throw new Error("Starting page index must be an integer."); | ||
if (options.startingPage < 0) | ||
throw new Error("Starting page index must be non-negative or zero."); | ||
if (options.startingPage > pages.length - 1) | ||
throw new Error("Starting page index is greater than the length of the pages."); | ||
} | ||
@@ -39,11 +45,19 @@ | ||
if (options.fastForwardAndRewind) { | ||
if (typeof options.fastForwardAndRewind !== "object") throw new Error("The 'fastForwardAndRewind' option should be an object."); | ||
if (typeof options.fastForwardAndRewind !== "object") | ||
throw new Error("The 'fastForwardAndRewind' option should be an object."); | ||
if (options.fastForwardAndRewind.time) { | ||
if (typeof options.time !== "number") throw new Error("Fast forward and rewind time must be a non-negative number."); | ||
if (options.fastForwardAndRewind.time < 0) throw new Error("Fast forward and rewind time must be non-negative."); | ||
if (typeof options.fastForwardAndRewind.time !== "number") | ||
throw new Error( | ||
"Fast forward and rewind time must be a non-negative number." | ||
); | ||
if (options.fastForwardAndRewind.time < 0) | ||
throw new Error("Fast forward and rewind time must be non-negative."); | ||
} | ||
if (options.fastForwardAndRewind.fastForwardPrompt) { | ||
if (typeof options.fastForwardAndRewind.fastForwardPrompt !== "string" || !options.fastForwardAndRewind.fastForwardPrompt.length) | ||
if ( | ||
typeof options.fastForwardAndRewind.fastForwardPrompt !== "string" || | ||
!options.fastForwardAndRewind.fastForwardPrompt.length | ||
) | ||
throw new Error("Prompt should be a string that is not empty."); | ||
@@ -53,3 +67,6 @@ } | ||
if (options.fastForwardAndRewind.rewindPrompt) { | ||
if (typeof options.fastForwardAndRewind.rewindPrompt !== "string" || !options.fastForwardAndRewind.rewindPrompt.length) | ||
if ( | ||
typeof options.fastForwardAndRewind.rewindPrompt !== "string" || | ||
!options.fastForwardAndRewind.rewindPrompt.length | ||
) | ||
throw new Error("Prompt should be a string that is not empty."); | ||
@@ -61,5 +78,7 @@ } | ||
if (options.goTo.prompt) { | ||
if (typeof options.goTo.prompt !== "string" || !options.goTo.prompt.length) throw new Error("Prompt should be a string that is not empty."); | ||
if (typeof options.goTo.prompt !== "string" || !options.goTo.prompt.length) | ||
throw new Error("Prompt should be a string that is not empty."); | ||
if (typeof options.goTo.time !== "number" || options.goTo.time < 0) throw new Error("Time must be non-negative number."); | ||
if (typeof options.goTo.time !== "number" || options.goTo.time < 0) | ||
throw new Error("Time must be non-negative number."); | ||
} | ||
@@ -75,3 +94,5 @@ } | ||
const emojis = options?.fastForwardAndRewind ? ["⏪", "◀️", "⏹", "▶️", "⏩"] : ["◀️", "⏹", "▶️"]; | ||
const emojis = options?.fastForwardAndRewind | ||
? ["⏪", "◀️", "⏹", "▶️", "⏩"] | ||
: ["◀️", "⏹", "▶️"]; | ||
@@ -86,3 +107,4 @@ if (options?.goTo) emojis.push("🔢"); | ||
const collector = pagination.createReactionCollector( | ||
(reaction: MessageReaction, user: User) => emojis.includes(reaction.emoji.name) && user.id === message.author.id, | ||
(reaction: MessageReaction, user: User) => | ||
emojis.includes(reaction.emoji.name) && user.id === message.author.id, | ||
{ | ||
@@ -99,3 +121,6 @@ dispose: true, | ||
if (!options?.fastForwardAndRewind) return; | ||
const rwp = await message.channel.send(options.fastForwardAndRewind.rewindPrompt || "How many pages would you like to go back?"); | ||
const rwp = await message.channel.send( | ||
options.fastForwardAndRewind.rewindPrompt || | ||
"How many pages would you like to go back?" | ||
); | ||
const rw = parseInt( | ||
@@ -140,3 +165,6 @@ ( | ||
if (!options?.fastForwardAndRewind) return; | ||
const ffp = await message.channel.send(options.fastForwardAndRewind.fastForwardPrompt || "How many pages would you like to go forward?"); | ||
const ffp = await message.channel.send( | ||
options.fastForwardAndRewind.fastForwardPrompt || | ||
"How many pages would you like to go forward?" | ||
); | ||
const ff = parseInt( | ||
@@ -166,3 +194,5 @@ ( | ||
const gtp = await message.channel.send(options.goTo.prompt || "Which page would you like to go to?"); | ||
const gtp = await message.channel.send( | ||
options.goTo.prompt || "Which page would you like to go to?" | ||
); | ||
@@ -169,0 +199,0 @@ const gt = parseInt( |
42540
884