Skip to main content

Actions

The ballerinax/discord package exposes the following clients:

ClientPurpose
ClientDiscord REST API v10: messages, channels, guilds, members, roles, webhooks, commands, events.

Client

Discord REST API v10: messages, channels, guilds, members, roles, webhooks, commands, events.

Configuration

FieldTypeDefaultDescription
authApiKeysConfig|OAuth2ClientCredentialsGrantConfig|BearerTokenConfig|OAuth2RefreshTokenGrantConfigRequiredAuthentication configuration. Use ApiKeysConfig for bot token, or an OAuth2 config for OAuth2 flows.
httpVersionHttpVersionHTTP_2_0HTTP protocol version.
timeoutdecimal30Request timeout in seconds.
retryConfigRetryConfig()Retry configuration for failed requests.
secureSocketClientSecureSocket()SSL/TLS configuration.
proxyProxyConfig()Proxy server configuration.

Initializing the client

import ballerinax/discord;

configurable string botToken = ?;

discord:Client discord = check new ({
auth: {
authorization: string `Bot ${botToken}`
}
});

Operations

Messages

Create message

Posts a new message to a channel.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel to send the message to.
payloadChannelIdMessagesBodyYesMessage content, embeds, attachments, and other message fields.

Returns: MessageResponse|error

Sample code:

discord:MessageResponse message = check discord->/channels/["1234567890"]/messages.post(
{contentType: "application/x-www-form-urlencoded"},
{content: "Hello from Ballerina!"}
);

Sample response:

{"id": "1199876543210", "channelId": "1234567890", "content": "Hello from Ballerina!", "author": {"id": "9876543210", "username": "BallerinaBot", "discriminator": "0001"}, "timestamp": "2024-12-01T10:30:00.000000+00:00", "editedTimestamp": null, "tts": false, "mentionEveryone": false, "pinned": false, "type": 0}
List messages

Retrieves a list of messages from a channel.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
queriesListMessagesQueriesNoQuery parameters including limit, before, after, and around message IDs.

Returns: MessageResponse[]|error

Sample code:

discord:MessageResponse[] messages = check discord->/channels/["1234567890"]/messages();

Sample response:

[{"id": "1199876543210", "channelId": "1234567890", "content": "Hello!", "author": {"id": "9876543210", "username": "BallerinaBot", "discriminator": "0001"}, "timestamp": "2024-12-01T10:30:00.000000+00:00", "type": 0}]
Get message

Retrieves a specific message by its ID.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message to retrieve.

Returns: MessageResponse|error

Sample code:

discord:MessageResponse message = check discord->/channels/["1234567890"]/messages/["1199876543210"];

Sample response:

{"id": "1199876543210", "channelId": "1234567890", "content": "Hello!", "author": {"id": "9876543210", "username": "BallerinaBot", "discriminator": "0001"}, "timestamp": "2024-12-01T10:30:00.000000+00:00", "type": 0}
Edit message

Edits a previously sent message.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message to edit.
payloadMessagesmessageIdBodyYesUpdated message content and fields.

Returns: MessageResponse|error

Sample code:

discord:MessageResponse updated = check discord->/channels/["1234567890"]/messages/["1199876543210"].patch(
{contentType: "application/x-www-form-urlencoded"},
{content: "Updated message content"}
);

Sample response:

{"id": "1199876543210", "channelId": "1234567890", "content": "Updated message content", "editedTimestamp": "2024-12-01T10:35:00.000000+00:00", "type": 0}
Delete message

Deletes a message from a channel.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message to delete.

Returns: error?

Sample code:

check discord->/channels/["1234567890"]/messages/["1199876543210"].delete();
Crosspost message

Crossposts (publishes) a message in an announcement channel to all following channels.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the announcement channel.
messageIdstringYesThe ID of the message to crosspost.

Returns: MessageResponse|error

Sample code:

discord:MessageResponse crossposted = check discord->/channels/["1234567890"]/messages/["1199876543210"]/crosspost.post();

Sample response:

{"id": "1199876543210", "channelId": "1234567890", "content": "Announcement!", "flags": 1, "type": 0}
Bulk delete messages

Deletes multiple messages in a single request (2–100 messages, not older than 14 days).

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
payloadChannelsMessagesBulkDeleteRequestYesObject containing an array of message IDs to delete.

Returns: error?

Sample code:

check discord->/channels/["1234567890"]/messages/bulk-delete.post({
messages: ["1199876543210", "1199876543211", "1199876543212"]
});

Channels

Get channel

Retrieves a channel by its ID.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.

Returns: InlineResponse2006|error

Sample code:

discord:InlineResponse2006 channel = check discord->/channels/["1234567890"];

Sample response:

{"id": "1234567890", "type": 0, "guildId": "9876543210", "name": "general", "position": 0, "permissionOverwrites": [], "topic": "General discussion", "nsfw": false}
Modify channel

Updates a channel's settings (name, topic, permissions, etc.).

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel to modify.
payloadChannelschannelIdBodyYesUpdated channel fields.

Returns: InlineResponse2006|error

Sample code:

discord:InlineResponse2006 updated = check discord->/channels/["1234567890"].patch({
name: "announcements",
topic: "Important announcements only"
});

Sample response:

{"id": "1234567890", "type": 0, "guildId": "9876543210", "name": "announcements", "topic": "Important announcements only", "position": 0}
Delete channel

Deletes a channel or closes a DM. Requires MANAGE_CHANNELS permission for guild channels.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel to delete.

Returns: InlineResponse2006|error

Sample code:

discord:InlineResponse2006 deleted = check discord->/channels/["1234567890"].delete();

Sample response:

{"id": "1234567890", "type": 0, "guildId": "9876543210", "name": "old-channel"}
List guild channels

Retrieves the list of channels in a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.

Returns: InlineResponseItems2007[]|error

Sample code:

discord:InlineResponseItems2007[] channels = check discord->/guilds/["9876543210"]/channels();

Sample response:

[{"id": "1234567890", "type": 0, "guildId": "9876543210", "name": "general", "position": 0}, {"id": "1234567891", "type": 2, "guildId": "9876543210", "name": "Voice Chat", "position": 1}]
Create guild channel

Creates a new channel in a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
payloadCreateGuildChannelRequestYesChannel creation payload with name, type, topic, and other settings.

Returns: GuildChannelResponse|error

Sample code:

discord:GuildChannelResponse newChannel = check discord->/guilds/["9876543210"]/channels.post({
name: "project-updates",
'type: 0,
topic: "Updates on the current project"
});

Sample response:

{"id": "1234567892", "type": 0, "guildId": "9876543210", "name": "project-updates", "topic": "Updates on the current project", "position": 5}

Guilds

Create guild

Creates a new guild (server). The bot can create guilds only if it is in fewer than 10 guilds.

Parameters:

NameTypeRequiredDescription
payloadGuildCreateRequestYesGuild creation payload with name and optional settings.

Returns: GuildResponse|error

Sample code:

discord:GuildResponse guild = check discord->/guilds.post({
name: "My New Server"
});

Sample response:

{"id": "9876543210", "name": "My New Server", "ownerId": "1111111111", "region": "us-west", "verificationLevel": 0, "defaultMessageNotifications": 0, "explicitContentFilter": 0}
Get guild

Retrieves a guild by its ID.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.

Returns: GuildWithCountsResponse|error

Sample code:

discord:GuildWithCountsResponse guild = check discord->/guilds/["9876543210"];

Sample response:

{"id": "9876543210", "name": "My Server", "ownerId": "1111111111", "memberCount": 150, "verificationLevel": 2, "premiumTier": 1}
Modify guild

Modifies a guild's settings (name, region, verification level, etc.).

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
payloadGuildPatchRequestPartialYesUpdated guild fields.

Returns: GuildResponse|error

Sample code:

discord:GuildResponse updated = check discord->/guilds/["9876543210"].patch({
name: "Renamed Server",
verificationLevel: 2
});

Sample response:

{"id": "9876543210", "name": "Renamed Server", "verificationLevel": 2, "ownerId": "1111111111"}
Delete guild

Permanently deletes a guild. The bot must be the guild owner.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild to delete.

Returns: error?

Sample code:

check discord->/guilds/["9876543210"].delete();
Get guild preview

Retrieves a guild preview (available for public/discoverable guilds).

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.

Returns: GuildPreviewResponse|error

Sample code:

discord:GuildPreviewResponse preview = check discord->/guilds/["9876543210"]/preview;

Sample response:

{"id": "9876543210", "name": "My Server", "description": "A cool server", "approximateMemberCount": 150, "approximatePresenceCount": 42, "emojis": [], "stickers": []}

Guild members

List guild members

Retrieves a list of guild members.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
queriesListGuildMembersQueriesNoQuery parameters including limit and after for pagination.

Returns: GuildMemberResponse[]|error

Sample code:

discord:GuildMemberResponse[] members = check discord->/guilds/["9876543210"]/members();

Sample response:

[{"user": {"id": "1111111111", "username": "Alice", "discriminator": "0001"}, "roles": ["2222222222"], "joinedAt": "2024-01-15T08:00:00.000000+00:00", "deaf": false, "mute": false}]
Get guild member

Retrieves a specific guild member by user ID.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
userIdstringYesThe ID of the user.

Returns: GuildMemberResponse|error

Sample code:

discord:GuildMemberResponse member = check discord->/guilds/["9876543210"]/members/["1111111111"];

Sample response:

{"user": {"id": "1111111111", "username": "Alice", "discriminator": "0001"}, "nick": "Ali", "roles": ["2222222222"], "joinedAt": "2024-01-15T08:00:00.000000+00:00", "deaf": false, "mute": false}
Remove guild member

Removes (kicks) a member from the guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
userIdstringYesThe ID of the user to remove.

Returns: error?

Sample code:

check discord->/guilds/["9876543210"]/members/["1111111111"].delete();
Add guild member role

Assigns a role to a guild member.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
userIdstringYesThe ID of the user.
roleIdstringYesThe ID of the role to assign.

Returns: error?

Sample code:

check discord->/guilds/["9876543210"]/members/["1111111111"]/roles/["2222222222"].put();
Remove guild member role

Removes a role from a guild member.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
userIdstringYesThe ID of the user.
roleIdstringYesThe ID of the role to remove.

Returns: error?

Sample code:

check discord->/guilds/["9876543210"]/members/["1111111111"]/roles/["2222222222"].delete();
Search guild members

Searches for guild members whose username or nickname starts with a given query string.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
queriesSearchGuildMembersQueriesYesSearch query parameters including query (search term) and optional limit.

Returns: GuildMemberResponse[]|error

Sample code:

discord:GuildMemberResponse[] results = check discord->/guilds/["9876543210"]/members/search(query = "Ali");

Sample response:

[{"user": {"id": "1111111111", "username": "Alice", "discriminator": "0001"}, "nick": "Ali", "roles": ["2222222222"], "joinedAt": "2024-01-15T08:00:00.000000+00:00"}]

Guild roles

List guild roles

Retrieves all roles in a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.

Returns: GuildRoleResponse[]|error

Sample code:

discord:GuildRoleResponse[] roles = check discord->/guilds/["9876543210"]/roles;

Sample response:

[{"id": "2222222222", "name": "Moderator", "color": 3447003, "hoist": true, "position": 1, "permissions": "2147483647", "managed": false, "mentionable": true}]
Create guild role

Creates a new role in a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
payloadGuildsRolesRequestYesRole creation payload with name, color, permissions, and other settings.

Returns: GuildRoleResponse|error

Sample code:

discord:GuildRoleResponse role = check discord->/guilds/["9876543210"]/roles.post({
name: "Contributors",
color: 3066993,
hoist: true,
mentionable: true
});

Sample response:

{"id": "3333333333", "name": "Contributors", "color": 3066993, "hoist": true, "position": 2, "permissions": "0", "managed": false, "mentionable": true}
Modify guild role

Modifies a guild role's settings.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
roleIdstringYesThe ID of the role to modify.
payloadGuildsRolesRequestYesUpdated role fields.

Returns: GuildRoleResponse|error

Sample code:

discord:GuildRoleResponse updated = check discord->/guilds/["9876543210"]/roles/["3333333333"].patch({
name: "Top Contributors",
color: 15105570
});

Sample response:

{"id": "3333333333", "name": "Top Contributors", "color": 15105570, "hoist": true, "position": 2, "permissions": "0", "managed": false, "mentionable": true}
Delete guild role

Deletes a guild role.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
roleIdstringYesThe ID of the role to delete.

Returns: error?

Sample code:

check discord->/guilds/["9876543210"]/roles/["3333333333"].delete();

Reactions

Create reaction

Adds a reaction to a message as the current user.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message.
emojiNamestringYesThe emoji to react with (URL-encoded Unicode emoji or name:id for custom).

Returns: error?

Sample code:

check discord->/channels/["1234567890"]/messages/["1199876543210"]/reactions/["🔴"]/'@me.put();
Get reactions

Retrieves the list of users who reacted with a specific emoji.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message.
emojiNamestringYesThe emoji to look up.

Returns: UserResponse[]|error

Sample code:

discord:UserResponse[] users = check discord->/channels/["1234567890"]/messages/["1199876543210"]/reactions/["🔴"];

Sample response:

[{"id": "1111111111", "username": "Alice", "discriminator": "0001", "avatar": "abc123", "bot": false, "flags": 0, "publicFlags": 0}]
Delete all reactions

Removes all reactions from a message.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message.

Returns: error?

Sample code:

check discord->/channels/["1234567890"]/messages/["1199876543210"]/reactions.delete();

Webhooks

Create webhook

Creates a new webhook for a channel.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
payloadChannelsWebhooksRequestYesWebhook creation payload with name and optional avatar.

Returns: GuildIncomingWebhookResponse|error

Sample code:

discord:GuildIncomingWebhookResponse webhook = check discord->/channels/["1234567890"]/webhooks.post({
name: "Build Notifications"
});

Sample response:

{"id": "5555555555", "type": 1, "guildId": "9876543210", "channelId": "1234567890", "name": "Build Notifications", "token": "webhook-token-here"}
Get webhook

Retrieves a webhook by its ID.

Parameters:

NameTypeRequiredDescription
webhookIdstringYesThe ID of the webhook.

Returns: InlineResponse2004|error

Sample code:

discord:InlineResponse2004 webhook = check discord->/webhooks/["5555555555"];

Sample response:

{"id": "5555555555", "type": 1, "guildId": "9876543210", "channelId": "1234567890", "name": "Build Notifications", "token": "webhook-token-here"}
Execute webhook

Executes a webhook by sending a message to its channel using the webhook token.

Parameters:

NameTypeRequiredDescription
webhookIdstringYesThe ID of the webhook.
webhookTokenstringYesThe webhook's token.
payloadWebhookIdwebhookTokenBodyYesMessage content, embeds, and other webhook execution fields.

Returns: MessageResponse|error?

Sample code:

discord:MessageResponse? res = check discord->/webhooks/["5555555555"]/["webhook-token-here"].post({
content: "Build #142 succeeded"
});

Sample response:

{"id": "5555555555", "type": 1, "guildId": "9876543210", "channelId": "1234567890", "name": "Build Notifications"}
Delete webhook

Permanently deletes a webhook.

Parameters:

NameTypeRequiredDescription
webhookIdstringYesThe ID of the webhook to delete.

Returns: error?

Sample code:

check discord->/webhooks/["5555555555"].delete();

Guild bans

List guild bans

Retrieves the list of bans for a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.

Returns: GuildBanResponse[]|error

Sample code:

discord:GuildBanResponse[] bans = check discord->/guilds/["9876543210"]/bans;

Sample response:

[{"reason": "Spamming", "user": {"id": "4444444444", "username": "BadUser", "discriminator": "9999"}}]
Ban user

Bans a user from the guild and optionally deletes their recent messages.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
userIdstringYesThe ID of the user to ban.

Returns: error?

Sample code:

check discord->/guilds/["9876543210"]/bans/["4444444444"].put();
Unban user

Removes a ban for a user.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
userIdstringYesThe ID of the user to unban.

Returns: error?

Sample code:

check discord->/guilds/["9876543210"]/bans/["4444444444"].delete();

Scheduled events

Create guild scheduled event

Creates a scheduled event in a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
payloadGuildIdScheduledEventsBodyYesScheduled event details including name, start time, privacy level, and entity type.

Returns: InlineResponse2003|error

Sample code:

var event = check discord->/guilds/["9876543210"]/scheduled-events.post({
name: "Community Meeting",
description: "Join us for our monthly community meeting!",
scheduledStartTime: "2024-12-31T23:59:59Z",
scheduledEndTime: "2025-01-01T01:00:00Z",
privacyLevel: 2,
entityType: 3,
entityMetadata: { location: "Virtual" }
});

Sample response:

{"id": "6666666666", "guildId": "9876543210", "name": "Community Meeting", "description": "Join us for our monthly community meeting!", "scheduledStartTime": "2024-12-31T23:59:59+00:00", "privacyLevel": 2, "status": 1, "entityType": 3}
List guild scheduled events

Retrieves the list of scheduled events for a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.

Returns: InlineResponseItems2004[]|error

Sample code:

var events = check discord->/guilds/["9876543210"]/scheduled-events;

Sample response:

[{"id": "6666666666", "guildId": "9876543210", "name": "Community Meeting", "scheduledStartTime": "2024-12-31T23:59:59+00:00", "privacyLevel": 2, "status": 1, "entityType": 3}]
Delete guild scheduled event

Deletes a scheduled event from a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.
guildScheduledEventIdstringYesThe ID of the scheduled event to delete.

Returns: error?

Sample code:

check discord->/guilds/["9876543210"]/scheduled-events/["6666666666"].delete();

Threads

Create thread from message

Creates a new thread from an existing message.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message to start the thread from.
payloadCreateTextThreadWithMessageRequestYesThread creation payload with name and optional auto-archive duration.

Returns: ThreadResponse|error

Sample code:

discord:ThreadResponse thread = check discord->/channels/["1234567890"]/messages/["1199876543210"]/threads.post({
name: "Discussion Thread"
});

Sample response:

{"id": "7777777777", "type": 11, "guildId": "9876543210", "name": "Discussion Thread", "parentId": "1234567890", "messageCount": 0, "memberCount": 1}
Create thread without message

Creates a new thread in a channel without an associated message.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
payloadChannelIdThreadsBodyYesThread creation payload with name, type, and optional settings.

Returns: CreatedThreadResponse|error

Sample code:

discord:CreatedThreadResponse thread = check discord->/channels/["1234567890"]/threads.post({
name: "New Discussion",
'type: 11
});

Sample response:

{"id": "7777777778", "type": 11, "guildId": "9876543210", "name": "New Discussion", "parentId": "1234567890", "messageCount": 0, "memberCount": 1}
List active threads

Retrieves all active threads in a guild.

Parameters:

NameTypeRequiredDescription
guildIdstringYesThe ID of the guild.

Returns: ThreadsResponse|error

Sample code:

discord:ThreadsResponse activeThreads = check discord->/guilds/["9876543210"]/threads/active;

Sample response:

{"threads": [{"id": "7777777777", "type": 11, "name": "Discussion Thread", "parentId": "1234567890"}], "members": [{"id": "7777777777", "userId": "1111111111"}], "hasMore": false}

Application commands

List global application commands

Retrieves all global application commands for the application.

Parameters:

NameTypeRequiredDescription
applicationIdstringYesThe ID of the application.

Returns: ApplicationCommandResponse[]|error

Sample code:

discord:ApplicationCommandResponse[] commands = check discord->/applications/["8888888888"]/commands;

Sample response:

[{"id": "9999999999", "applicationId": "8888888888", "name": "ping", "description": "Replies with Pong!", "type": 1, "version": "1"}]
Create global application command

Creates a new global application command (slash command).

Parameters:

NameTypeRequiredDescription
applicationIdstringYesThe ID of the application.
payloadApplicationCommandCreateRequestYesCommand definition with name, description, type, and options.

Returns: ApplicationCommandResponse|error

Sample code:

discord:ApplicationCommandResponse command = check discord->/applications/["8888888888"]/commands.post({
name: "greet",
description: "Sends a greeting message",
'type: 1
});

Sample response:

{"id": "9999999998", "applicationId": "8888888888", "name": "greet", "description": "Sends a greeting message", "type": 1, "version": "1"}
Delete global application command

Deletes a global application command.

Parameters:

NameTypeRequiredDescription
applicationIdstringYesThe ID of the application.
commandIdstringYesThe ID of the command to delete.

Returns: error?

Sample code:

check discord->/applications/["8888888888"]/commands/["9999999998"].delete();

Users

Get current user

Retrieves the currently authenticated user's information.

Returns: UserPIIResponse|error

Sample code:

discord:UserPIIResponse me = check discord->/users/'@me;

Sample response:

{"id": "1111111111", "username": "BallerinaBot", "discriminator": "0001", "email": "[email protected]", "verified": true, "flags": 0, "publicFlags": 0}
Get user

Retrieves a user by their ID.

Parameters:

NameTypeRequiredDescription
userIdstringYesThe ID of the user.

Returns: UserResponse|error

Sample code:

discord:UserResponse user = check discord->/users/["1111111111"];

Sample response:

{"id": "1111111111", "username": "Alice", "discriminator": "0001", "avatar": "abc123", "bot": false, "flags": 0, "publicFlags": 0}
List current user guilds

Retrieves the guilds the current user is a member of.

Returns: MyGuildResponse[]|error

Sample code:

discord:MyGuildResponse[] guilds = check discord->/users/'@me/guilds;

Sample response:

[{"id": "9876543210", "name": "My Server", "owner": true, "permissions": "2147483647"}]

Invites

Get invite

Retrieves an invite by its code.

Parameters:

NameTypeRequiredDescription
codestringYesThe invite code.

Returns: InlineResponse2002|error

Sample code:

discord:InlineResponse2002 invite = check discord->/invites/["abc123"];

Sample response:

{"code": "abc123", "guild": {"id": "9876543210", "name": "My Server"}, "channel": {"id": "1234567890", "name": "general", "type": 0}}
Delete invite

Deletes an invite by its code. Requires MANAGE_CHANNELS permission.

Parameters:

NameTypeRequiredDescription
codestringYesThe invite code to revoke.

Returns: InlineResponse2002|error

Sample code:

discord:InlineResponse2002 invite = check discord->/invites/["abc123"].delete();

Channel pins

List pinned messages

Retrieves all pinned messages in a channel.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.

Returns: MessageResponse[]|error

Sample code:

discord:MessageResponse[] pinned = check discord->/channels/["1234567890"]/pins;

Sample response:

[{"id": "1199876543210", "channelId": "1234567890", "content": "Important announcement", "pinned": true, "type": 0}]
Pin message

Pins a message in a channel (max 50 pins per channel).

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message to pin.

Returns: error?

Sample code:

check discord->/channels/["1234567890"]/pins/["1199876543210"].put();
Unpin message

Unpins a message from a channel.

Parameters:

NameTypeRequiredDescription
channelIdstringYesThe ID of the channel.
messageIdstringYesThe ID of the message to unpin.

Returns: error?

Sample code:

check discord->/channels/["1234567890"]/pins/["1199876543210"].delete();