Discord module

The Discord module is an importable module that allows you to interact with Discord. To use it, import it like this:

local d = require('discord');
d.send("Hello world!")

send(message: string)

Sends a text message in Discord. You can send up to 5 messages per custom function. You can also use this to mention people, but @everyone and @here and mentioning roles will not work.

local d = require('discord');
d.send("Hello, <@"..message.author.id..">!")
-- Responds: Hello @Big P!

run(command: string)

Runs an OcelotBOT command as if the user running the custom function had run it. The command is run in the context of the triggering message, as if the user that triggered the function and will send the output into the channel. Some commands can't be run inside a custom command, and some commands may not act as expected.

Commands do not have to contain the prefix to work, including the prefix will still work but if you change the prefix after the fact the custom command will need to be updated.

local d = require('discord');
d.run("8ball am I running inside a custom command?")

runWithSettings(command: string, settings: table)

Runs an OcelotBOT command with specific settings. This is an advanced function that will allow you to customise OcelotBOT command responses beyond what is possible normally. For a list of possible uses, check the Command Settings page.

local d = require('discord');
-- Displays the 5th page from the command !reddit aww and disabled the page buttons
d.runWithSettings("!reddit aww", {["pagination.page"]=5,["pagination.disabled"]=1})

playAudio(url: string)

Plays a single audio track, can be a YouTube URL or any audio file or stream. Can always be stopped with !music stop, and will not interrupt currently playing music or guessing games. Joins the voice channel the triggering user is in.

local d = require('discord');
d.playAudio("https://www.youtube.com/watch?v=_htnaGN8eOs");

paginate(pages: string[])

Paginate uses OcelotBOT's standard reaction-based pagination, to display each page in pages as a separate message.

local d = require('discord');
d.paginate({"This is page 1", "This is page 2", "This is page 3"})

react(emoji: string)

Reacts to the trigger message with the specified emoji ID.

To get the emoji ID, type a backslash (\) then the emoji you want and send it in Discord. You will see something like this: <:yikes:813555460598267924>

The ID is the number, so "813555460598267924" in this case.

local d = require('discord');
d.react("813555460598267924"); -- The yikes emoji from above

webhook(message: string, username: string, avatar: string)

Allows you to send a message as a webhook, with a specific username and avatar.

local d = require('discord');
d.webhook("Identity theft is not a joke", message.author.username, message.author.avatar);

Last updated