Frequently Asked Questions

Some very quick code samples for common actions on the bot, users, members, channels and messages!

In this page, some very basic, frequently-asked questions are answered. It's important to understand that these examples are generic and will most likely not work if you just copy/paste them in your code. You need to understand these lines, not just blindly shove them in your code.

Code Examples

Bot and Bot Client

// Set the bot's "Playing: " status (must be in an event!)
client.on("ready", () => {
    client.user.setActivity("my code", { type: "WATCHING"})
})
// Set the bot's online/idle/dnd/invisible status
client.on("ready", () => {
    client.user.setStatus("online");
});
// Set the bot's presence (activity and status)
client.on("ready", () => {
    client.user.setPresence({
        activities: [{ 
          name: "my code",
          type: "WATCHING"
        }],
        status: "idle"
    })
})

Note: You can find a list of all possible activity types here.

If you want your bot's status to show up as STREAMING, you need to provide a Twitch or YouTube URL. For setActivity, you need to provide an options object, which needs to have the URL, and the type should be set to streaming. For setPresence, you need to provide the presence data object, which needs to contain the activities array, with the url and type (Set it to "STREAMING").

Users and Members

In these examples Guild is a placeholder for where you get the guild. This can be message.guild or member.guild or just guild depending on the event. Or, you can get the guild by ID (see next section) and use that, too!

Channels and Guilds

Messages

Last updated