Skip to content

Bot

Top level documentation for the Discord-Luau library, welcome! 👋

This package will represent the entrypoint to your adventure using Discord-Luau, through this package you’ll generate a discord Bot object, this bot Object enables you to write discord bots for the Discord API.

local DiscordLuau = require("/path/to/discord-luau")
local Bot = DiscordLuau.bot -- This module!
local discordBot = Bot.new({
token = env.DISCORD_BOT_TOKEN,
reconnect = env.IS_PRODUCTION,
intents = 513, -- Guild, GuildMessages
})
discordBot:connectAsync():await()
print(`Bot has connected: '{discordBot.user.username}'`)

Properties

The Bot instance has no set properties!

Methods

The Bot instance has no set methods!

Functions

queryGatewayInformation

Bot . queryGatewayInformation (

     self: Bot
)  -> ()

Queries the Discord Gateway for bot information.

This function sends a request to the Discord Gateway to retrieve information about the bot, such as the recommended number of shards and session start limit.

connectAsync

Bot . connectAsync (

     self: Bot
)  -> ()

Connects the bot to the Discord gateway asynchronously.

This function performs the following steps:

  1. Queries gateway information
  2. Asserts that the query was successful
  3. Connects to the WebSocket using the obtained gateway information

Returns a async that resolves when the connection is established.

getGuildAsync

Bot . getGuildAsync (

     self: Bot
     guildId: string
     withCount: boolean?
)  -> ()

Returns the classes.guild object for the given id. If with_counts is set to true, this endpoint will also return approximate_member_count and approximate_presence_count for the classes.guild.

getChannelAsync

Bot . getChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a channel. The channel type is determined by the generic type parameter T.

getDMChannelAsync

Bot . getDMChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a DM channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a DM channel.

getGroupDMChannelAsync

Bot . getGroupDMChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a Group DM channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a Group DM channel.

getAnnouncementChannelAsync

Bot . getAnnouncementChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns an announcement channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about an announcement channel.

getCategoryChannelAsync

Bot . getCategoryChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a category channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a category channel.

getDirectoryChannelAsync

Bot . getDirectoryChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a directory channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a directory channel.

getStageVCChannelAsync

Bot . getStageVCChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a stage voice channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a stage voice channel.

getTextChannelAsync

Bot . getTextChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a text channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a text channel.

getForumChannelAsync

Bot . getForumChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a text channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a text channel.

getMediaChannelAsync

Bot . getMediaChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a text channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a text channel.

getUserAsync

Bot . getUserAsync (

     self: Bot
     userId: string
)  -> ()

Returns a user object for the given user ID.

This function sends a request to the Discord API to retrieve information about a user.

createGuildAsync

Bot . createGuildAsync (

     self: Bot
     guildData: {
      {… name: string, …}    }
)  -> ()

Will create a new Guild instance, returns this instance.

setLogLevel

Bot . setLogLevel (

     self: Bot
     logLevel: logger.LogLevel
)  -> ()

Will set the Log Level for the bot, and all instantiated objects within the bot.

getVoiceChannelAsync

Bot . getVoiceChannelAsync (

     self: Bot
     channelId: string
)  -> ()

Returns a voice channel object for the given channel ID.

This function sends a request to the Discord API to retrieve information about a voice channel.

setPresenceAsync

Bot . setPresenceAsync (

     self: Bot
     presence: builders.presenceJSON
)  -> ()

Allows you to set the presence for the Discord Bot.

new

Bot . new (

     options: {
       token: string,
       intents: number,
       reconnect: boolean?,
       logLevel: logger.LogLevel?,
       globalRatelimit: number?,
    }
)  -> ()

Construct a new DiscordLuau object