Moonhook API Reference¶
General Functions¶
moonhook.Option¶
Creates an option in the Main Menu, Webhooks Menu or Bots Menu.
Pass in moonhook.MAIN_MENU_OPTION, moonhook.WEBHOOKS_OPTION or moonhook.BOTS_OPTION as the type argument.
moonhook.Request¶
moonhook.Request(
options: {
Url: string,
Method: "GET" | "POST" | string,
Headers: { [string]: string },
Body: string
}
) -> {
Success: boolean,
StatusCode: number,
StatusMessage: string,
Body: string
}
moonhook.encode and moonhook.decode functions to encode and decode JSON from Luau tables.
Console Library¶
moonhook.log¶
Logs text to the console.
moonhook.error¶
Logs an error to the console.
Warning
This function does not stop execution. use return or error() to actually stop execution after calling moonhook.error.
moonhook.input¶
Recieves text input from the user.
moonhook.int_input¶
Recieves input from the user as a number. Defaults to 0.
moonhook.setcolors¶
moonhook.setcolors(
gradient_start: { r: number, g: number, b: number },
gradient_end: { r: number, g: number, b: number }
) -> nil
moonhook.setbanner¶
Originaly a ConsoleHelper class function, ported to luau for shits and giggles.
Call this before calling moonhook.printbanner
moonhook.printbanner¶
Prints a banner to the console with a gradient. Call the moonhook.setcolors and moonhoom.setbanner functions before calling this function.
moonhook.wait¶
Sleeps for a specified amount of milliseconds. Execution will be paused until this function finishes.
moonhook.pause¶
Prompts the user to press Space / Enter to continue. Execution will be paused until the user completes the action.
Filesystem Library¶
Note
All filesystem functions are only allowed to run within the Workspace folder. The workspace folder is located in ./Plugins/Workspace within your Moonhook installation folder.
Note
The following extensions are blocked from the filesystem functions:
.exe, .scr, .vbs, .bat, .cmd, .com, .msi,
.ps1, .psm1, .psd1,
.vbe, .wsf, .wsh, .js, .jse, .hta,
.cpl, .msc, .reg, .inf,
.lnk, .pif,
.dll, .sys,
.jar, .py, .sh, .rb, .application, .gadget,
.ws, .sct, .crt
moonhook.readfile¶
Reads a file inside of the workspace folder and returns it's content as a string.
moonhook.writefile¶
Writes a string to a file inside of the workspace folder.
moonhook.appendfile¶
Appends content to a file inside of the workspace folder.
moonhook.makefolder¶
Creates a folder inside of the Workspace folder.
moonhook.delfolder¶
Deletes a folder from the Workspace folder.
Constants¶
const moonhook.MAIN_MENU_OPTION = 0;
const moonhook.WEBHOOKS_OPTION = 1;
const moonhook.BOTS_OPTION = 2;
ctx object¶
Webhook Options¶
- ctx.url (The webhook URL)
- ctx.new() (Function to create a
Webhookobject)
Bot Options¶
- ctx.token (The discord bot token)
- ctx.guild_id (The provieded discord guild ID)
- ctx.new() (Function to create a
Botobject)
Webhook class¶
Note
To create an object of this class, use the ctx object provided when you register a Webhooks menu option.
Webhook:send¶
Sends a message to the discord webhook. If the function succeeds, it will return true, otherwise false.
Webhook:set_proxy¶
Sets a HTTP proxy.
Webhook:get_proxy¶
Gets the currently active HTTP proxy.
Webhook:last_error¶
Returns the last occured error as a string.
Webhook:retry_after_ms¶
If the webhook has been rate limited, will return the amount of time left until you can send another HTTP request in milliseconds.
Webhook:set_name¶
Sets the name of the discord webhook by making an HTTP request. Returns true on success, and false on failure.
Webhook:set_avatar_from_url¶
Sets the avatar of the discord webhook by making an HTTP request. Returns true on success, and false on failure.
Webhook:set_avatar_from_file¶
Sets the avatar of the discord webhook by making an HTTP request. Same as set_avatar_from_url, but sets the discord webhook avatar by reading an image file. Returns true on success, and false on failure.
Webhook:get_name¶
Returns the name of the discord webhook as a string. Returns an empty string on failure.
Webhook.delete_webhook¶
Deletes the discord webhook. Returns true on success, and false on failure.
Warning
After this function is called, the discord webhook will be deleted and will no longer be usable!
Bot class¶
Bot:validate_guild¶
Checks if a guild is valid and exists. If the guild exists, the guild name will be returned as a string. Otherwise, an empty string will be returned.
Bot:get_channels¶
Bot:get_channels(guild_id: string) -> {
id: string,
name: string,
type: number -- 0 = text, 2 = voice, 4 = category
}
Note
Discord guild channels have 3 types. 0 is a text channel, 2 is a voice channel and 4 is a category.
Bot:delete_channel¶
Attempts to delete a discord channel. Will return true on success and false on failure.
Bot:create_text_channel¶
Attempts to create a discord channel. Will return true on success and false on failure.
Bot:get_roles¶
Returns all the roles in the discord server.
Bot:delete_role¶
Attempts to delete a discord role. Will return true on success and false on failure.
Bot:get_members¶
Bot:get_members(guild_id: string, owner_id: string) -> {
user_id: string,
username: string,
discriminator: string,
is_owner: boolean
}
Note
In the Bot:get_members function, if you do not have the discord guild owner's ID, just pass an empty string as the last argument. The function will still work properly, however it will just not detect is_owner.
Bot:ban_member()¶
Attempts to ban a discord user from the specified guild with the specified reason. Returns true on success, and false on failure.
Bot:create_webhook¶
Bot:create_webhook(channel_id: string, webhook_name: string) -> {
id: string,
token: string,
url: string
}
true on success and false on failure.