#Paginated Message Replies Only to Interactions?

1 messages · Page 1 of 1 (latest)

calm onyx
#

When I use a paginated message from @sapphire/discord.js-utilities with an interaction and call the run method it replies to the original interaction. However when I follow the same process with a message object it does not reply to the original message. I was wondering if this is perhaps an intents issue or the like but having given the bot all intents and scoured the docs I still can't find a solution. Any help would be much appreciated.

smoky solsticeBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

bold coral
#

This is intended. If you want it to reply to the original message, you'll have to extend the PaginatedMessage class. Use the following code:

export class CustomPaginatedMessage extends PaginatedMessage {
    protected async setUpMessage(messageOrInteraction: Message | AnyInteractableInteraction): Promise<void> {
        // Get the current page
        let page = this.messages[this.index]!;

        // Merge in the advanced options
        page = { ...page, ...(this.paginatedMessageData ?? {}) };

        if (this.response) {
            if (isAnyInteraction(this.response)) {
                if (this.response.replied || this.response.deferred) {
                    await this.response.editReply(page);
                } else {
                    await this.response.reply({ ...page, content: page.content ?? undefined });
                }
            } else if (isMessageInstance(this.response)) {
                await this.response.edit(page);
            }
        } else if (isAnyInteraction(messageOrInteraction)) {
            if (messageOrInteraction.replied || messageOrInteraction.deferred) {
                const editReplyResponse = await messageOrInteraction.editReply(page);
                this.response = messageOrInteraction.ephemeral ? messageOrInteraction : editReplyResponse;
            } else {
                this.response = await messageOrInteraction.reply({
                    ...page,
                    content: page.content ?? undefined,
                    fetchReply: true,
                    ephemeral: false
                });
            }
        } else if (!isStageChannel(messageOrInteraction.channel)) {
            this.response = await messageOrInteraction.reply({ ...page, content: page.content ?? undefined });
        }
    }
}

Note: I directly copied the original function, just changing messageOrInteraction.channel.send to messageOrInteraction.reply.

#

I haven't tested this out, so it might not be typesafe. However, the solution will be something along those lines.

#

@calm onyx

calm onyx
#

That actually works perfectly. Thankyou :)