Creating your First Prompt - TimmyRB/SydneyBot GitHub Wiki

Make sure to follow the instructions on How to Create a Command before continuing.

First, let's modify our imports

import { Permissions, MessageEmbed } from "discord.js";
import { Command, Prompt } from "../../lib/models/bot";

Next, we'll create a Prompt in our Command's callback

callback: (msg, args, dbUser) => {
    let prompt = new Prompt({
        content: [
            new MessageEmbed()
        ]
    })
}
  • content - An Array of MessageEmbeds that will each be used as one page

Let's add some info to our Embed & run .show() to send our Prompt to the same channel the User ran the Command

callback: (msg, args, dbUser) => {
    let prompt = new Prompt({
        content: [
            new MessageEmbed({
                title: 'Page 1'
            })
        ]
    })

    prompt.show(msg.channel, msg.author.id)
}

As we can see, running the Command sends the prompt to the channel

Now let's try adding more pages

callback: (msg, args, dbUser) => {
    let prompt = new Prompt({
        content: [
            new MessageEmbed({
                title: 'Page 1'
            }),
            new MessageEmbed({
                title: 'Page 2'
            }),
            new MessageEmbed({
                title: 'Page 3'
            })
        ]
    })

    prompt.show(msg.channel, msg.author.id)
}

Now when we send the Command, since there is more than one page, arrow reactions appear and pressing them changes the page!