Discord Namespace
Thediscord namespace provides functions to interact with Discord’s API.
Scripts are written in JavaScript and executed by the Go client using Goja.
discord.send_message()
Send a message to a Discord channel.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | The Discord channel ID to send the message to |
content | string | The message content to send |
Returns
void
Example
discord.edit_message()
Edit an existing Discord message.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | The Discord channel ID where the message is located |
messageId | string | The message ID to edit |
content | string | The new message content |
Returns
void
Example
discord.delete_message()
Delete a Discord message.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | The Discord channel ID where the message is located |
messageId | string | The message ID to delete |
Returns
void
Example
discord.http_get()
Make an HTTP GET request to an external API.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | The URL to make a GET request to |
Returns
HttpResponse - An object containing:
| Property | Type | Description |
|---|---|---|
status | number | HTTP status code (e.g., 200, 404) |
data | string | Response body as a string |
headers | object | Response headers |
Example
Notes
- Only
GETrequests are supported - Be mindful of rate limits on external APIs
- Always handle errors with try/catch
- Response data is always a string - use
JSON.parse()if needed
discord.fetch_message()
Fetch a Discord message by its ID.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID where the message is |
messageId | string | Message ID to fetch |
Returns
Message or null if not found
Example
discord.fetch_guild()
Fetch a Discord guild/server by its ID.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID to fetch |
Returns
Guild or null if not found
Example
discord.fetch_channel()
Fetch a Discord channel by its ID.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID to fetch |
Returns
Channel or null if not found
Example
discord.fetch_user()
Fetch a Discord user by their ID.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | User ID to fetch |
Returns
Author or null if not found
Example
discord.add_reaction()
Add a reaction to a message.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID |
messageId | string | Message ID |
emoji | string | Emoji (e.g., “+1” or custom emoji name) |
Returns
boolean - true if successful
Example
discord.remove_reaction()
Remove a reaction from a message.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID |
messageId | string | Message ID |
emoji | string | Emoji to remove |
userId | string | User ID (optional, defaults to self) |
Returns
boolean - true if successful
Example
discord.send_typing()
Send typing indicator in a channel.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID |
Returns
boolean - true if successful
Example
discord.pin_message()
Pin a message in a channel.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID |
messageId | string | Message ID to pin |
Returns
boolean - true if successful
Example
discord.unpin_message()
Unpin a message in a channel.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID |
messageId | string | Message ID to unpin |
Returns
boolean - true if successful
discord.add_role()
Add a role to a member.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
userId | string | User ID |
roleId | string | Role ID to add |
Returns
boolean - true if successful
Example
discord.remove_role()
Remove a role from a member.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
userId | string | User ID |
roleId | string | Role ID to remove |
Returns
boolean - true if successful
discord.kick_member()
Kick a member from a guild.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
userId | string | User ID to kick |
Returns
boolean - true if successful
Example
discord.ban_member()
Ban a member from a guild.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
userId | string | User ID to ban |
deleteMessageDays | number | Days of messages to delete (0-7, optional) |
Returns
boolean - true if successful
Example
discord.unban_member()
Unban a member from a guild.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
userId | string | User ID to unban |
Returns
boolean - true if successful
discord.leave_guild()
Leave a guild/server.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID to leave |
Returns
boolean - true if successful
discord.create_dm()
Create a DM channel with a user.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | User ID |
Returns
DM channel object withid property, or null if failed
Example
discord.get_messages()
Get recent messages from a channel.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID |
limit | number | Number of messages (max 100, optional, default: 100) |
Returns
Array of message objectsExample
discord.create_channel()
Create a new channel in a guild.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
name | string | Channel name |
type | number | Channel type (0=text, 2=voice, 4=category, 5=news, optional, default: 0) |
options | object | Optional settings (topic, nsfw, parent_id, position) |
Returns
Channel object or null if failed
Example
discord.edit_channel()
Edit an existing channel.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID to edit |
options | object | Properties to update (name, topic, nsfw, position, parent_id) |
Returns
boolean - true if successful
Example
discord.delete_channel()
Delete a channel.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
channelId | string | Channel ID to delete |
Returns
boolean - true if successful
Example
discord.create_role()
Create a new role in a guild.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
options | object | Optional role properties (name, color, hoist, mentionable) |
Returns
Role object ornull if failed
Example
discord.edit_role()
Edit an existing role.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
roleId | string | Role ID to edit |
options | object | Properties to update (name, color, hoist, mentionable, position) |
Returns
boolean - true if successful
Example
discord.delete_role()
Delete a role from a guild.Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
roleId | string | Role ID to delete |
Returns
boolean - true if successful
Example
discord.edit_member()
Edit a guild member (nickname, roles, etc.).Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
guildId | string | Guild ID |
userId | string | User ID to edit |
options | object | Properties to update (nick, roles) |
Returns
boolean - true if successful