OcelotBOT
Search…
Discord module
The Discord module is an importable module that allows you to interact with Discord. To use it, import it like this:
1
local d = require('discord');
2
d.send("Hello world!")
Copied!

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.
1
local d = require('discord');
2
d.send("Hello, <@"..message.author.id..">!")
3
-- Responds: Hello @Big P!
Copied!

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.
1
local d = require('discord');
2
d.run("8ball am I running inside a custom command?")
Copied!

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.
1
local d = require('discord');
2
-- Displays the 5th page from the command !reddit aww and disabled the page buttons
3
d.runWithSettings("!reddit aww", {["pagination.page"]=5,["pagination.disabled"]=1})
Copied!

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.
1
local d = require('discord');
2
d.playAudio("https://www.youtube.com/watch?v=_htnaGN8eOs");
Copied!

paginate(pages: string[])

Paginate uses OcelotBOT's standard reaction-based pagination, to display each page in pages as a separate message.
1
local d = require('discord');
2
d.paginate({"This is page 1", "This is page 2", "This is page 3"})
Copied!

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.
1
local d = require('discord');
2
d.react("813555460598267924"); -- The yikes emoji from above
Copied!

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

Allows you to send a message as a webhook, with a specific username and avatar.
1
local d = require('discord');
2
d.webhook("Identity theft is not a joke", message.author.username, message.author.avatar);
Copied!
Last modified 4mo ago