3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-14 05:45:02 +00:00

Pre-plugin moves

This commit is contained in:
Dark 2021-05-31 21:12:24 +02:00
parent 9fc045cd38
commit 8f7a6510eb
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
13 changed files with 62 additions and 52 deletions

View file

@ -1,9 +1,18 @@
import { APIMessage, Client, Message, MessageReaction, PartialUser, TextChannel, User } from "discord.js";
import {
APIMessage,
Client,
Message,
MessageOptions,
MessageReaction,
PartialUser,
TextChannel,
User,
} from "discord.js";
import { Awaitable } from "knub/dist/utils";
import { MINUTES, noop } from "../utils";
import Timeout = NodeJS.Timeout;
export type LoadPageFn = (page: number) => Awaitable<MessageContent>;
export type LoadPageFn = (page: number) => Awaitable<MessageOptions>;
export interface PaginateMessageOpts {
timeout: number;
@ -24,7 +33,7 @@ export async function createPaginatedMessage(
): Promise<Message> {
const fullOpts = { ...defaultOpts, ...opts } as PaginateMessageOpts;
const firstPageContent = await loadPageFn(1);
const message = await channel.send(firstPageContent);
const message = await channel.send({ content: firstPageContent });
let page = 1;
let pageLoadId = 0; // Used to avoid race conditions when rapidly switching pages