Bot class

const bot = new Bot(addon: Addon);

constructor

The constructor of the Bot class requires one argument, which is the Addon class of the addon where to create the bot for.

Properties

username

The username of the bot.

id

The user id of the bot and is a Twitter snowflake.

avatarURL

The url of the avatar of the bot.

tag

The username of the bot including the discriminator.

created

An instance of the NodeJS built-in Date class which represents the date when the bot was created.

createdTimestamp

A number which represents the timestamp of the date when the bot was created.

Functions

setActivity

bot.setActivity(activity: string) : Promise<void>;

Updates the activity of the bot and returns a Promise which gets fulfilled once the activity of the bot has been updated.

ArgumentDescription

activity

A string which represents the activity of the bot.

setActivityType

bot.setActivityType(activityType: string) : Promise<void>;

Updates the activity type of the bot. This will decide whether the bot is 'Playing' or 'Watching' the activity for example. The function returns a Promise which gets fulfilled once the activity type of the bot has been updated.

ArgumentDescription

activityType

A string which defines the activity type of the bot. Possible activity types are: watching, listening, competing, playing and streaming. When the activity type has been set to streaming, it is required to add a streaming url using the setStreamingURL function.

setStreamingURL

bot.setStreamingURL(streamURL: string) : Promise<void>;

Sets a streaming url for the activity of the bot. This will show the users which stream the bot is streaming. This must be a YouTube or Twitch stream. Other streams won't be allowed by the Discord API. To add a streaming url, it is required to set the activity type to streaming using the setActivityType function. The function returns a Promise which gets fulfilled once the stream url has been changed.

ArgumentDescription

streamURL

The url of the stream which should be shown in the activity status of the bot. This must be a YouTube or Twitch url.

setStatusType

bot.setStatusType(statusType: string) : Promise<void>;

Changes the status of the bot and shows whether the bot is online or idle for example. The function returns a Promise which gets fulfilled once the status type has been changed.

ArgumentDescription

statusType

A string which defines the status type of the bot. Possible status types are: online, idle, dnd (do not disturb) or offline.

setUsername

bot.setUsername(username: string) : Promise<void>;

Changes the username of the bot. The function returns a Promise which gets fulfilled once the username of the bot has been changed. Changing the username may also change the discriminator of the bot.

ArgumentDescription

username

The new username for the bot. The value must be a string.

setAvatar

bot.setAvatar(avatar: string | Buffer) : Promise<void>;

Changes the avatar of the bot. The function returns a Promise which gets fulfilled once the avatar of the bot has been changed.

ArgumentDescription

avatar

A url of the image, the path of the image or an instance of the NodeJS built-in Buffer class which defines the avatar you want to give the bot.

Last updated