Remedy.API (Remedy v0.6.8) View Source
Standard interface for the Discord API.
The majority of the functions within this module are pulled directly from the Discord API. Some custom implementations are included.
Ratelimits
Discord imposes rate limits in various capacities. The functions in this module will respect those rate limits where possible. If required, a request will be held until it is allowed to be completed.
Cache Interaction
This module does not automagically interract with the cache.
Return Values
Items returned from the API are parsed to ensure the values of in the correct format and types.
List vs Get?
Functions in the discord API that return lists are randomly called either Get or List for some arbitrary reason. This is rectified so that all functions returning lists will start with the verb list.
Edit vs Modify?
The functions have been normalized to :modify
.
Note: This one is anyones guess, just saying if I can pick or the other with a $2 mcmuffin in my hand. Discord can figure it out with 400 mil in the bank. I made them all
:modify
because its cuter.
Permissions
Any permissions a bot requires on a server to send a request is shown under the function.
Intents
If a privileged intent is required for a request to be completed, it is also shown under the function.
Missing Functions
The following functions were not migrated from Nostrum
:get_user_dms
Link to this section Summary
Functions
Puts a user in a guild.
Adds a role to a member.
Begins a guild prune to prune members within days
.
Deletes multiple messages from a channel.
Overwrite the existing global application commands.
Overwrite the existing guild application commands on the specified guild.
Creates an invite for a guild channel.
Create a new DM channel with a user.
Create a followup message for an interaction.
Create a new global application command.
Creates a new group DM channel.
Bans a user from a guild.
Creates a channel for a guild.
Creates a new emoji for the given guild.
Creates a guild role.
Create a response to an interaction received from the gateway.
Posts a message to a guild text or DM channel.
Creates a reaction for a message.
Creates a webhook.
Deletes all reactions from a message.
Deletes all reactions of a given emoji from a message.
Deletes a channel.
Delete a channel permission for a user or role.
Delete a followup message for an interaction.
Delete an existing global application command.
Deletes a guild.
Deletes the given emoji.
Deletes a guild integeration.
Deletes a role from a guild.
Deletes an invite by its invite_code
.
Deletes a message.
Deletes a reaction the bot has made for the message.
Deletes another user's reaction from a message.
Deletes a webhook.
Executes a github webhook.
Executes a slack webhook.
Executes a webhook.
Get a channel.
Gets a list of invites for a channel.
Retrieves a message from a channel.
Gets the authorization information for the Bot.
Gets the bot's OAuth2 application info.
Gets info on the current user.
Gets a list of guilds the user is currently in.
Gets a gateway URL.
Gets a Gateway Bot Object.
Fetch all global commands.
Gets a guild.
Get an audit log.
Gets a ban object for the given user from a guild.
Gets a list of guild channels.
Gets an emoji for the given guild and emoji ids.
Gets a list of guild integerations.
Gets a guild member.
Gets the number of members that would be removed in a prune given days
.
Gets an invite by its invite_code
.
Gets all users who reacted with an emoji.
Returns a sticker object.
Gets a user by its t:Remedy.Schema.User.id/0
.
Gets a list of user connections.
Gets a webhook by id.
Gets a webhook by id and token.
add recipient to a group DM
Leaves a guild.
List active threads.
Gets a list of webook for a channel.
Gets a list of users banned from a guild.
Gets a list of emojis for a given guild.
Gets a list of invites for a guild.
Gets a list of a guild's members.
Gets a guild's roles.
Gets a list of voice regions for the guild.
Gets a list of webooks for a guild.
Retrieves a channel's messages.
List messages after a given message.
List messages around a given message.
List messages before a given message.
Retrieves all pinned messages from a channel.
Gets a list of voice regions.
Modifies a channel's settings.
Edit the permission overwrites for a user or role.
Changes the username or avatar of the current user.
Update an existing global application command.
Modify a group DM.
Modifies a guild's settings.
Reorders a guild's channels.
Modify the given emoji.
Modifies a guild member's attributes.
Modifies a guild role.
Reorders a guild's roles.
Edits a previously sent message in a channel.
Modify a News Channel.
Modifies the nickname of the current user in a guild.
Modify a Text Channel.
Modify thread.
Modify a Voice Channel.
Modifies a webhook.
Modifies a webhook with a token.
Pins a message in a channel.
Publish a message in a news channel.
Removes a ban for a user.
Removes a member from a guild.
Removes a role from a member.
Starts a thread.
Triggers the typing indicator.
Unpins a message in a channel.
Link to this section Types
Link to this section Functions
Puts a user in a guild.
Permissions
CREATE_INSTANT_INVITE
MANAGE_NICKNAMES
*MANAGE_ROLES
*MUTE_MEMBERS
*DEAFEN_MEMBERS
*
Events
:GUILD_MEMBER_ADD
Options
:access_token
(string) - the user's oauth2 access token:nick
(string) - value to set users nickname to:roles
(list oft:Remedy.Schema.Guild.Role.id/0
) - array of role ids the member is assigned:mute
(boolean) - if the user is muted:deaf
(boolean) - if the user is deafened
:access_token
is always required.
Examples
iex> Remedy.API.add_guild_member(
...> 41771983423143937,
...> 18374719829378473,
...> access_token: "6qrZcUqja7812RVdnEKjpzOL4CvHBFG",
...> nick: "remedy",
...> roles: [431849301, 913809431])
Adds a role to a member.
Role to add is specified by role_id
.
User to add role to is specified by guild_id
and user_id
.
An optional reason
can be given for the audit log.
batch_modify_application_command_permissions(guild_id)
View Source (since 0.6.0)Begins a guild prune to prune members within days
.
An optional reason
can be provided for the guild audit log.
This endpoint requires the KICK_MEMBERS
permission. It fires multiple
Remedy.Consumer.guild_member_remove/0
events.
If successful, returns {:ok, %{pruned: pruned}}
. Otherwise, returns a Remedy.API.error/0
.
Examples
iex> Remedy.API.begin_guild_prune(81384788765712384, 1)
{:ok, %{pruned: 0}}
Deletes multiple messages from a channel.
messages
is a list of Remedy.Schema.Message.id
that you wish to delete.
When given more than 100 messages, this function will chunk the given message
list into blocks of 100 and send them off to the API. It will stop deleting
on the first error that occurs. Keep in mind that deleting thousands of
messages will take a pretty long time and it may be proper to just delete
the channel you want to bulk delete in and recreate it.
This method can only delete messages sent within the last two weeks.
Filter
is an optional parameter that specifies whether messages sent over
two weeks ago should be filtered out; defaults to true
.
Overwrite the existing global application commands.
This action will:
- Create any command that was provided and did not already exist
- Update any command that was provided and already existed if its configuration changed
- Delete any command that was not provided but existed on Discord's end
Updates will be available in all guilds after 1 hour. Commands that do not already exist will count toward daily application command create limits.
Parameters
application_id
: Application ID for which to overwrite the commands. If not given, this will be fetched fromMe
.commands
: List of command configurations, see the linked API documentation for reference.
Return value
Updated list of global application commands. See the official reference: https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
Overwrite the existing guild application commands on the specified guild.
This action will:
- Create any command that was provided and did not already exist
- Update any command that was provided and already existed if its configuration changed
- Delete any command that was not provided but existed on Discord's end
Parameters
application_id
: Application ID for which to overwrite the commands. If not given, this will be fetched fromMe
.guild_id
: Guild on which to overwrite the commands.commands
: List of command configurations, see the linked API documentation for reference.
Return value
Updated list of guild application commands. See the official reference: https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-guild-application-commands
Creates an invite for a guild channel.
An optional reason
can be provided for the audit log.
This endpoint requires the CREATE_INSTANT_INVITE
permission.
If successful, returns {:ok, invite}
. Otherwise, returns a Remedy.API.error/0
.
Options
:max_age
(integer) - duration of invite in seconds before expiry, or 0 for never. (default:86400
):max_uses
(integer) - max number of uses or 0 for unlimited. (default:0
):temporary
(boolean) - Whether the invite should grant temporary membership. (default:false
):unique
(boolean) - used when creating unique one time use invites. (default:false
)
Examples
iex> Remedy.API.create_channel_invite(41771983423143933)
{:ok, Remedy.Schema.Invite{}}
iex> Remedy.API.create_channel_invite(41771983423143933, max_uses: 20)
{:ok, %Remedy.Schema.Invite{}}
Create a new DM channel with a user.
If successful, returns {:ok, dm_channel}
. Otherwise, returns a Remedy.API.error/0
.
Examples
iex> Remedy.API.create_dm(150061853001777154)
{:ok, %Remedy.Schema.Channel{type: 1}}
Create a followup message for an interaction.
Delegates to execute_webhook/3
, see the function for more details.
Create a new global application command.
The new command will be available on all guilds in around an hour.
If you want to test commands, use create_guild_application_command/2
instead,
as commands will become available instantly there.
If an existing command with the same name exists, it will be overwritten.
Parameters
application_id
: Application ID for which to create the command. If not given, this will be fetched fromMe
.command
: Command configuration, see the linked API documentation for reference.
Return value
The created command. See the official reference: https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
Example
iex> Remedy.API.create_application_command(%{name: "edit", description: "ed, man! man, ed", options: []})
{:ok, %Remedy.Schema.Command{}}
Creates a new group DM channel.
If successful, returns {:ok, group_dm_channel}
. Otherwise, returns a Remedy.API.error/0
.
access_tokens
are user oauth2 tokens. nicks
is a map that maps a user id
to a nickname.
Examples
iex> Remedy.API.create_group_dm(["6qrZcUqja7812RVdnEKjpzOL4CvHBFG"], %{41771983423143937 => "My Nickname"})
{:ok, %Remedy.Schema.Channel{type: 3}}
create_guild_application_command(guild_id, command_id)
View Source (since 0.6.0)Bans a user from a guild.
User to delete is specified by guild_id
and user_id
.
An optional reason
can be specified for the audit log.
Creates a channel for a guild.
Permissions
MANAGE_CHANNELS
Events
:CHANNEL_CREATE
Options
:name
(string) - channel name (2-100 characters):type
(integer) - the type of channel (SeeRemedy.Schema.Channel
):topic
(string) - channel topic (0-1024 characters):bitrate
(integer) - the bitrate (in bits) of the voice channel (voice only):user_limit
(integer) - the user limit of the voice channel (voice only):permission_overwrites
(list oft:Remedy.Schema.Overwrite.t/0
or equivalent map) - the channel's permission overwrites:parent_id
- id of the parent category for a channel:nsfw
(boolean) - if the channel is nsfw
Examples
iex> Remedy.API.create_guild_channel(81384788765712384, name: "elixir-remedy", topic: "craig's domain")
{:ok, %Remedy.Schema.Channel{guild_id: 81384788765712384}}
Creates a new emoji for the given guild.
This endpoint requires the MANAGE_EMOJIS
permission. It fires a
Remedy.Consumer.guild_emojis_update/0
event.
An optional reason
can be provided for the audit log.
If successful, returns {:ok, emoji}
. Otherwise, returns Remedy.API.error/0
.
Options
:name
(string) - name of the emoji:image
(base64 data URI) - the 128x128 emoji image. Maximum size of 256kb:roles
list of - roles for which this emoji will be whitelisted (default: [])
:name
and :image
are always required.
Examples
iex> image = "data:image/png;base64,YXl5IGJieSB1IGx1a2luIDQgc3VtIGZ1az8="
...> Remedy.API.create_guild_emoji(43189401384091, name: "remedy", image: image, roles: [])
Creates a guild role.
An optional reason for the audit log can be provided via reason
.
This endpoint requires the MANAGE_ROLES
permission. It fires a
Remedy.Consumer.guild_role_create/0
event.
If successful, returns {:ok, role}
. Otherwise, returns a Remedy.API.error/0
.
Options
:name
(string) - name of the role (default: "new role"):permissions
(integer) - bitwise of the enabled/disabled permissions (default: @everyone perms):color
(integer) - RGB color value (default: 0):hoist
(boolean) - whether the role should be displayed separately in the sidebar (default: false):mentionable
(boolean) - whether the role should be mentionable (default: false)
Examples
iex> Remedy.API.create_guild_role(41771983423143937, name: "remedy-club", hoist: true)
{:ok, %Remedy.Schema.Role{}}
Create a response to an interaction received from the gateway.
Parameters
id
: The interaction ID to which the response should be created.token
: The interaction token.response
: AnInteractionResponse
object. See the linked documentation.
Example
As an alternative to passing the interaction ID and token, the
original Remedy.Schema.Interaction.t/0
can also be passed
directly. See create_interaction_response/1
.
Posts a message to a guild text or DM channel.
Intents
:VIEW_CHANNEL
:SEND_MESSAGES
:SEND_MESSAGES_TTS
(optional)
Events
t:Remedy.Gateway.Dispatch.message_create/0
.
Options
:content
(string) - the message contents (up to 2000 characters):tts
(boolean) - true if this is a TTS message:file
(Path.t/0
| map) - the path of the file being sent, or a map with the following keys if sending a binary from memory:name
(string) - the name of the file:body
(string) - binary you wish to send:embed
(Remedy.Schema.Embed.t/0
) - embedded rich content:allowed_mentions
- See "Allowed mentions" below:message_reference
(map
) - See "Message references" below
Note: At least one of the following is required:
:content
,:file
,:embed
.
Allowed mentions
:all
(default) - Ping everything as usual:none
- Nobody will be pinged:everyone
- Allows to ping @here and @everone:users
- Allows to ping users:roles
- Allows to ping roles{:users, list}
- Allows to ping list of users. Can contain up to 100 ids of users.{:roles, list}
- Allows to ping list of roles. Can contain up to 100 ids of roles.
Examples
iex> {:ok, message} = Remedy.API.create_message(872417560094732331, content: "**Doctest Message** ✅")
...> message.content
"**Doctest Message** ✅"
Creates a reaction for a message.
Permissions
VIEW_CHANNEL
READ_MESSAGE_HISTORY
ADD_REACTIONS
()
Examples
iex> Remedy.API.create_reaction(123123123123, 321321321321,
...> %Remedy.Schema.Emoji{id: 43819043108, name: "foxbot"}
...> )
:ok
iex> Remedy.API.create_reaction(123123123123, 321321321321, "😁")
Creates a webhook.
Parameters
channel_id
- Id of the channel to send the message to.args
- Map with the following required keys:name
- Name of the webhook.avatar
- Base64 128x128 jpeg image for the default avatar.
reason
- An optional reason for the guild audit log.
Deletes all reactions from a message.
Permissions
VIEW_CHANNEL
,READ_MESSAGE_HISTORY
MANAGE_MESSAGES
Events
:MESSAGE_REACTION_REMOVE_ALL
.
Examples
Deletes all reactions of a given emoji from a message.
Permissions
MANAGE_MESSAGES
Events
:MESSAGE_REACTION_REMOVE_EMOJI
If successful, returns {:ok}
. Otherwise, returns Remedy.API.error/0
.
See create_reaction/3
for similar examples.
Specs
Deletes a channel.
An optional reason
can be provided for the guild audit log.
Permissions
MANAGE_CHANNELS
Events
:CHANNEL_DELETE
Examples
iex> Remedy.API.delete_channel(421533712753360896) {:ok, %Remedy.Schema.Channel{id: 421533712753360896}}
iex> Remedy.API.delete_channel(123)
Delete a channel permission for a user or role.
Role or user overwrite to delete is specified by channel_id
and overwrite_id
.
An optional reason
can be given for the audit log.
Delete a followup message for an interaction.
Parameters
application_id
: Application ID for which to create the command. If not given, this will be fetched fromMe
.token
: Interaction token.message_id
: Followup message ID.
Delete an existing global application command.
Parameters
application_id
: Application ID for which to create the command. If not given, this will be fetched fromMe
.command_id
: The current snowflake of the command.
Deletes a guild.
This endpoint requires that the current user is the owner of the guild.
Events
:GUILD_DELETE
Examples
iex> Remedy.API.delete_guild(618432108653707274)
{:error, {403, 50001, "Missing Access"}}
iex> Remedy.API.delete_guild(618432108653707274)
{:error, {403, 50001, "Missing Access"}}
delete_guild_application_command(guild_id, command_id)
View Source (since 0.6.0)Deletes the given emoji.
An optional reason
can be provided for the audit log.
This endpoint requires the MANAGE_EMOJIS
permission. It fires a
Remedy.Consumer.guild_emojis_update/0
event.
If successful, returns {:ok}
. Otherwise, returns Remedy.API.error/0
.
Deletes a guild integeration.
Integration to delete is specified by guild_id
and integeration_id
.
Deletes a role from a guild.
An optional reason
can be specified for the audit log.
This endpoint requires the MANAGE_ROLES
permission. It fires a
Remedy.Consumer.guild_role_delete/0
event.
If successful, returns {:ok}
. Otherwise, returns a Remedy.API.error/0
.
Examples
iex> Remedy.API.delete_guild_role(41771983423143937, 392817238471936)
Deletes an invite by its invite_code
.
This endpoint requires the MANAGE_CHANNELS
permission.
If successful, returns {:ok, invite}
. Otherwise, returns a
Remedy.API.error/0
.
Examples
iex> Remedy.API.delete_invite("zsjUsC")
{:ok, %Remedy.Schema.Invite{}}
Deletes a message.
Permissions
- 'VIEW_CHANNEL'
- 'MANAGE_MESSAGES'
Events
MESSAGE_DELETE
Examples
iex> Remedy.API.delete_message(43189401384091, 43189401384091)
delete_original_interaction_response(interaction_token)
View Source (since 0.6.0)Deletes a reaction the bot has made for the message.
Permissions
VIEW_CHANNEL
READ_MESSAGE_HISTORY
Events
:MESSAGE_REACTION_REMOVE
Examples
iex> Remedy.API.delete_own_reaction(123, 123, 123)
{:ok}
Deletes another user's reaction from a message.
Permissions
VIEW_CHANNEL
READ_MESSAGE_HISTORY
MANAGE_MESSAGES
Examples
iex>
Deletes a webhook.
Parameters
webhook_id
- Id of webhook to delete.reason
- An optional reason for the guild audit log.
delete_webhook_message(webhook_id, webhook_token, message_id)
View Source (since 0.6.0)delete_webhooks_with_token(webhook_id, webhook_token)
View Source (since 0.6.0)Executes a github webhook.
Parameters
webhook_id
- Id of the webhook to execute.webhook_token
- Token of the webhook to execute.
Executes a slack webhook.
Parameters
webhook_id
- Id of the webhook to execute.webhook_token
- Token of the webhook to execute.
Executes a webhook.
## Parameters
webhook_id
- Id of the webhook to execute.webhook_token
- Token of the webhook to execute.args
- Map with the following required keys:content
- Message content.file
- File to send.embeds
- List of embeds to send.username
- Overrides the default name of the webhook.avatar_url
- Overrides the default avatar of the webhook.tts
- Whether the message should be read over text to speech.
wait
- Whether to return an error or not. Defaults tofalse
.
Only one of content
, file
or embeds
should be supplied in the args
parameter.
get_application_command_permissions(guild_id, command_id)
View Source (since 0.6.0)Specs
get_channel(snowflake() | Remedy.Schema.Channel.t()) :: {:error, any()} | {:ok, Remedy.Schema.Channel.t()}
Get a channel.
Examples
iex> {:ok, channel} = Remedy.API.get_channel(872417560094732331)
...> channel.id
872417560094732331
Gets a list of invites for a channel.
This endpoint requires the 'VIEW_CHANNEL' and 'MANAGE_CHANNELS' permissions.
If successful, returns {:ok, invite}
. Otherwise, returns a
Remedy.API.error/0
.
Examples
iex> Remedy.API.get_channel_invites(43189401384091)
{:ok, [%Remedy.Schema.Invite{}]}
Specs
get_channel_message(snowflake(), snowflake()) :: {:error, any()} | {:ok, Remedy.Schema.Message.t()}
Retrieves a message from a channel.
Permissions
- 'VIEW_CHANNEL'
- 'READ_MESSAGE_HISTORY'
Examples
iex> Remedy.API.get_channel_message(872417560094732331, 884355195277025321) {:ok, %Remedy.Schema.Message{}}
Specs
Gets the authorization information for the Bot.
This is currently unused by any of the connections employed by Remedy and is included for completeness only.
Examples
iex> Remedy.API.get_current_authorization_information()
{:error, {401, 50001, "Missing Access"}}
Specs
get_current_bot_application_information() :: {:error, any()} | {:ok, Remedy.Schema.App.t()}
Gets the bot's OAuth2 application info.
Examples
iex> Remedy.API.get_application_information()
{:ok, %Remedy.Schema.App{}
Gets info on the current user.
If remedy's caching is enabled, it is recommended to use Bot.get/0
instead of this function. This is because sending out an API request is much slower
than pulling from our cache.
If the request is successful, this function returns {:ok, user}
, where
user
is remedy's Remedy.Schema.User
. Otherwise, returns {:error, reason}
.
Gets a list of guilds the user is currently in.
This endpoint requires the guilds
OAuth2 scope.
If successful, returns {:ok, guilds}
. Otherwise, returns a Remedy.API.error/0
.
Options
:before
- get guilds before this guild ID:after
- get guilds after this guild ID:limit
(integer) - max number of guilds to return (1-100)
Examples
iex> Remedy.API.get_current_user_guilds(limit: 1)
{:ok, [%Remedy.Schema.Guild{}]}
Specs
Gets a gateway URL.
Examples
iex> Remedy.API.get_gateway()
{:ok, "wss://gateway.discord.gg"}
Gets a Gateway Bot Object.
Fetch all global commands.
Parameters
application_id
: Application ID for which to search commands. If not given, this will be fetched fromMe
.
Return value
A list of ApplicationCommand
s on success. See the official reference:
https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
Example
iex> Remedy.API.get_global_application_commands
{:ok, [%{application_id: "455589479713865749"}]}
Gets a guild.
Examples
iex> Remedy.API.get_guild(81384788765712384)
{:ok, %Remedy.Schema.Guild{id: 81384788765712384}}
Specs
get_guild_audit_log(snowflake() | Remedy.Schema.Guild.t(), opts()) :: {:error, any()} | {:ok, Remedy.Schema.AuditLog.t()}
Get an audit log.
Query Options
:user_id
- filter the log for actions made by a user.:action_type
- the type of audit log event:before
- filter the log before a certain entry id:limit
- how many entries are returned (default 50, minimum 1, maximum 100)
Examples
iex> Remedy.API.get_guild_audit_log(872417560094732328)
{:ok, %Remedy.Schema.AuditLog{}}
iex> Remedy.API.get_guild_audit_log(123)
{:error, {403, 10004, "Unknown Guild"}}
Gets a ban object for the given user from a guild.
Gets a list of guild channels.
Examples
iex> Remedy.API.get_guild_channels(81384788765712384)
{:ok, [%Remedy.Schema.Channel{guild_id: 81384788765712384}]}
Gets an emoji for the given guild and emoji ids.
This endpoint requires the MANAGE_EMOJIS
permission.
If successful, returns {:ok, emoji}
. Otherwise, returns Remedy.API.error/0
.
Gets a list of guild integerations.
Guild to get integrations for is specified by guild_id
.
Gets a guild member.
Examples
iex> Remedy.API.get_guild_member(4019283754613, 184937267485)
Gets the number of members that would be removed in a prune given days
.
This endpoint requires the KICK_MEMBERS
permission.
If successful, returns {:ok, %{pruned: pruned}}
. Otherwise, returns a Remedy.API.error/0
.
Examples
iex> Remedy.API.get_guild_prune_count(81384788765712384, 1)
{:ok, %{pruned: 0}}
Gets an invite by its invite_code
.
If successful, returns {:ok, invite}
. Otherwise, returns a
Remedy.API.error/0
.
Options
:with_counts
(boolean) - whether to include member count fields
Examples
iex> Remedy.API.get_invite("zsjUsC")
{:ok, %Remedy.Schema.Invite{}}
iex> Remedy.API.get_invite("zsjUsC", with_counts: true)
{:ok, %Remedy.Schema.Invite{}}
get_original_interaction_response(interaction_token)
View Source (since 0.6.0)Gets all users who reacted with an emoji.
This endpoint requires the VIEW_CHANNEL
and READ_MESSAGE_HISTORY
permissions.
If successful, returns {:ok, users}
. Otherwise, returns Remedy.API.error/0
.
See create_reaction/3
for similar examples.
Specs
get_sticker(snowflake()) :: {:error, any()} | {:ok, %Remedy.Schema.Sticker{ __meta__: term(), asset: term(), available: term(), description: term(), format_type: term(), guild: term(), guild_id: term(), id: term(), name: term(), sort_value: term(), sticker_pack: term(), sticker_pack_id: term(), tags: term(), type: term(), user: term(), user_id: term() }}
Returns a sticker object.
Examples
iex> Remedy.API.get_sticker(818599312882794506)
{:ok, %Remedy.Schema.Sticker{}}
iex> Remedy.API.get_sticker(123)
{:error, {404, 10060, "Unknown sticker"}}
Gets a user by its t:Remedy.Schema.User.id/0
.
If the request is successful, this function returns {:ok, user}
, where
user
is a Remedy.Schema.User
. Otherwise, returns {:error, reason}
.
Gets a list of user connections.
Gets a webhook by id.
Parameters
webhook_id
- Id of the webhook to get.
get_webhook_message(webhook_id, webhook_token, message_id)
View Source (since 0.6.0)Gets a webhook by id and token.
This method is exactly like get_webhook/1
but does not require
authentication.
Parameters
webhook_id
- Id of the webhook to get.webhook_token
- Token of the webhook to get.
add recipient to a group DM
Leaves a guild.
Guild to leave is specified by guild_id
.
Specs
list_active_threads(Remedy.Schema.Channel.t() | Remedy.Schema.Guild.t()) :: {:error, any()} | {:ok, any()}
List active threads.
Note: This can be requested on both the
/channels/
and the/guilds/
routes. To specify which route is used, you should pass a full%Guild{}
or%Channel{}
object.
Gets a list of webook for a channel.
Parameters
channel_id
- Channel to get webhooks for.
Gets a list of users banned from a guild.
Guild to get bans for is specified by guild_id
.
Gets a list of emojis for a given guild.
This endpoint requires the MANAGE_EMOJIS
permission.
If successful, returns {:ok, emojis}
. Otherwise, returns Remedy.API.error/0
.
Gets a list of invites for a guild.
This endpoint requires the MANAGE_GUILD
permission.
If successful, returns {:ok, invites}
. Otherwise, returns a Remedy.API.error/0
.
Examples
iex> Remedy.API.get_guild_invites(81384788765712384)
{:ok, [%Remedy.Schema.Invite{}]}
Gets a list of a guild's members.
Options
:limit
(integer) - max number of members to return (1-1000) (default: 1):after
(t:Remedy.Schema.User.id/0
) - the highest user id in the previous page (default: 0)
Examples
iex> Remedy.API.list_guild_members(41771983423143937, limit: 1)
Gets a guild's roles.
If successful, returns {:ok, roles}
. Otherwise, returns a Remedy.API.error/0
.
Examples
iex> Remedy.API.get_guild_roles(147362948571673)
{:ok, [%Remedy.Schema.Role{}]}
Gets a list of voice regions for the guild.
Guild to get voice regions for is specified by guild_id
.
Gets a list of webooks for a guild.
Parameters
guild_id
- Guild to get webhooks for.
Specs
Retrieves a channel's messages.
Permissions
VIEW_CHANNEL
READ_MESSAGE_HISTORY
Options
:before
*:after
*:around
*:limit
- Only one may be provided.
Helpers
Examples
iex> Remedy.API.list_messages(872417560094732331, [{:before, 882781809908256789}, {:limit, 1}])
{:ok, [%Message{id: 882681855315423292}]}
Specs
List messages after a given message.
Specs
List messages around a given message.
Specs
List messages before a given message.
Retrieves all pinned messages from a channel.
Permissions
- 'VIEW_CHANNEL'
- 'READ_MESSAGE_HISTORY'
Examples
iex> Remedy.API.get_pinned_messages(43189401384091)
Gets a list of voice regions.
modify_application_command_permissions(guild_id, command_id)
View Source (since 0.6.0)Specs
modify_channel(snowflake(), map(), reason()) :: {:error, any()} | {:ok, Remedy.Schema.Channel.t()}
Modifies a channel's settings.
Permissions
MANAGE_CHANNEL
Events
:CHANNEL_UPDATE
.
Options
:name
(string) - 2-100 character channel name:position
(integer) - the position of the channel in the left-hand listing:topic
(string) - 0-1024 character channel topic:nsfw
(boolean) - if the channel is nsfw:bitrate
(integer) - the bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers):user_limit
(integer) - the user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit:permission_overwrites
(list oft:Remedy.Schema.Overwrite.t/0
or equivalent map) - channel or category-specific permissions:parent_id
- id of the new parent category for a channel
Examples
iex> Remedy.API.modify_channel(41771983423143933, name: "elixir-remedy", topic: "remedy discussion") {:ok, %Remedy.Schema.Channel{id: 41771983423143933, name: "elixir-remedy", topic: "remedy discussion"}}
Edit the permission overwrites for a user or role.
Role or user to overwrite is specified by overwrite_id
.
permission_info
is a map with the following keys:
type
- Required;member
if editing a user,role
if editing a role.allow
- Bitwise value of allowed permissions.deny
- Bitwise value of denied permissions.type
-member
if editing a user,role
if editing a role.
An optional reason
can be provided for the audit log.
allow
and deny
are defaulted to 0
, meaning that even if you don't
specify them, they will override their respective former values in an
existing overwrite.
Changes the username or avatar of the current user.
Options
:username
(string) - new username:avatar
(string) - the user's avatar as avatar data
Examples
iex> Remedy.API.modify_current_user(avatar: "data:image/jpeg;base64,YXl5IGJieSB1IGx1a2luIDQgc3VtIGZ1az8=")
{:ok, %Remedy.Schema.User{}}
modify_followup_message(interaction_token, message_id)
View Source (since 0.6.0)Update an existing global application command.
The updated command will be available on all guilds in around an hour.
Parameters
application_id
: Application ID for which to edit the command. If not given, this will be fetched fromMe
.command_id
: The current snowflake of the command.command
: Command configuration, see the linked API documentation for reference.
Return value
The updated command. See the official reference: https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
Specs
modify_group_dm( Remedy.Schema.Channel.t() | snowflake(), keyword(), nil | binary() ) :: {:error, any()} | {:ok, Remedy.Schema.Channel.t()}
Modify a group DM.
This function validates the options before passing them to Remedy.API.modify_channel/3
Events:
:CHANNEL_UPDATE
Examples
iex> Remedy.API.modify_group_dm(872417560094732331, [{:name, "hello"}], "felt like it")
{:ok, %Channel{}}
Modifies a guild's settings.
Permissions
MANAGE_GUILD
Events
:GUILD_UPDATE
Options
:name
(string) - guild name:region
(string) - guild voice region id:verification_level
(integer) - verification level:default_message_notifications
(integer) - default message notification level:explicit_content_filter
(integer) - explicit content filter level:afk_channel_id
- id for afk channel:afk_timeout
(integer) - afk timeout in seconds:icon
(base64 data URI) - 128x128 jpeg image for the guild icon:owner_id
- user id to transfer guild ownership to (must be owner):splash
(base64 data URI) - 128x128 jpeg image for the guild splash (VIP only):system_channel_id
- the id of the channel to which system messages are sent:rules_channel_id
- the id of the channel that is used for rules in public guilds:public_updates_channel_id
- the id of the channel where admins and moderators receive notices from Discord in public guilds
Examples
iex> Remedy.API.modify_guild(451824027976073216, name: "Nose Drum")
{:ok, %Remedy.Schema.Guild{id: 451824027976073216, name: "Nose Drum", ...}}
modify_guild_application_command(guild_id, command_id)
View Source (since 0.6.0)Reorders a guild's channels.
Permissions
MANAGE_CHANNELS
Events
:CHANNEL_UPDATE
Options
positions
Examples
iex> Remedy.API.modify_guild_channel_positions(279093381723062272, [%{id: 351500354581692420, position: 2}])
{:ok}
iex> Remedy.API.modify_guild_channel_positions(279093381723062272, [%{id: 351500354581692420, position: 2}])
{:ok}
Modify the given emoji.
This endpoint requires the MANAGE_EMOJIS
permission. It fires a
Remedy.Consumer.guild_emojis_update/0
event.
An optional reason
can be provided for the audit log.
If successful, returns {:ok, emoji}
. Otherwise, returns Remedy.API.error/0
.
Options
:name
(string) - name of the emoji:roles
- roles to which this emoji will be whitelisted
Examples
iex> Remedy.API.modify_guild_emoji(43189401384091, 4314301984301, name: "elixir", roles: [])
{:ok, %Remedy.Schema.Emoji{}}
Modifies a guild member's attributes.
Permissions
MANAGE_NICKNAMES
MANAGE_ROLES
MUTE_MEMBERS
DEAFEN_MEMBERS
MOVE_MEMBERS
Events
:GUILD_MEMBER_UPDATE
Options
:nick
(string) - value to set users nickname to:roles
- array of role ids the member is assigned:mute
(boolean) - if the user is muted:deaf
(boolean) - if the user is deafened:channel_id
- id of channel to move user to (if they are connected to voice)
Examples
iex> Remedy.API.modify_guild_member(41771983423143937, 637162356451, nick: "Remedy")
{:ok}
Modifies a guild role.
This endpoint requires the MANAGE_ROLES
permission. It fires a
Remedy.Consumer.guild_role_update/0
event.
An optional reason
can be specified for the audit log.
If successful, returns {:ok, role}
. Otherwise, returns a Remedy.API.error/0
.
Options
:name
(string) - name of the role:permissions
(integer) - bitwise of the enabled/disabled permissions:color
(integer) - RGB color value (default: 0):hoist
(boolean) - whether the role should be displayed separately in the sidebar:mentionable
(boolean) - whether the role should be mentionable
Examples
iex> Remedy.API.modify_guild_role(41771983423143937, 392817238471936, hoist: false, name: "foo-bar")
Reorders a guild's roles.
This endpoint requires the MANAGE_ROLES
permission. It fires multiple
Remedy.Consumer.guild_role_update/0
events.
If successful, returns {:ok, roles}
. Otherwise, returns a Remedy.API.error/0
.
positions
is a list of maps that each map a role id with a position.
Examples
iex> Remedy.API.modify_guild_role_positions(41771983423143937, [%{id: 41771983423143936, position: 2}])
Edits a previously sent message in a channel.
Permissions
VIEW_CHANNEL
Events
:MESSAGE_UPDATE
.
Options
:content
(string) - the message contents (up to 2000 characters):embed
(Remedy.Schema.Embed.t/0
) - embedded rich content
Examples
iex> Remedy.API.modify_message(889614079830925352, 1894013840914098, content: "hello world!")
{:ok}
iex> Remedy.API.modify_message(889614079830925352, 1894013840914098, "hello world!")
{:ok}
Modify a News Channel.
This function validates the options before passing them to Remedy.API.modify_channel/3
Permissions
MANAGE_CHANNELS
MANAGE_ROLES
(If modifying permission overwrites)
Events:
:CHANNEL_UPDATE
Examples
iex> Remedy.API.modify_news_channel(872417560094732331, [{:name, "hello"}], "felt like it")
{:ok, %Channel{}}
Modifies the nickname of the current user in a guild.
Options
:nick
(string) - value to set users nickname to
Examples
iex> Remedy.API.modify_nickname(41771983423143937, nick: "Remedy")
{:ok, %{nick: "Remedy"}}
iex>
modify_original_interaction_response(interaction_token)
View Source (since 0.6.0)Specs
modify_text_channel(Remedy.Schema.Channel.t() | snowflake(), opts(), reason()) :: {:error, any()} | {:ok, Remedy.Schema.Channel.t()}
Modify a Text Channel.
This function validates the options before passing them to Remedy.API.modify_channel/3
Permissions
MANAGE_CHANNELS
MANAGE_ROLES
(If modifying permission overwrites)
Events:
:CHANNEL_UPDATE
Examples
iex> Remedy.API.modify_group_dm(872417560094732331, [{:name, "hello"}], "felt like it") {:ok, %Channel{}}
Modify thread.
This function validates the options before passing them to Remedy.API.modify_channel/3
Permissions
MANAGE_THREADS
SEND_MESSAGES
(If modifying permission overwrites)
Events:
:THREAD_UPDATE
Examples
iex> Remedy.API.modify_group_dm(872417560094732331, [{:name, "hello"}], "felt like it")
{:ok, %Channel{}}
Modify a Voice Channel.
This function validates the options before passing them to Remedy.API.modify_channel/3
Permissions
MANAGE_CHANNELS
MANAGE_ROLES
(If modifying permission overwrites)
Events:
:CHANNEL_UPDATE
Examples
iex> Remedy.API.voice_channel(872417560094732331, [{:name, "hello"}], "felt like it")
{:ok, %Channel{}}
Modifies a webhook.
Parameters
webhook_id
- Id of the webhook to modify.args
- Map with the following optional keys:name
- Name of the webhook.avatar
- Base64 128x128 jpeg image for the default avatar.
reason
- An optional reason for the guild audit log.
modify_webhook_message(webhook_id, webhook_token, message_id)
View Source (since 0.6.0)Modifies a webhook with a token.
This method is exactly like modify_webhook/1
but does not require
authentication.
Parameters
webhook_id
- Id of the webhook to modify.webhook_token
- Token of the webhook to get.args
- Map with the following optional keys:name
- Name of the webhook.avatar
- Base64 128x128 jpeg image for the default avatar.
reason
- An optional reason for the guild audit log.
Pins a message in a channel.
Permissions
'VIEW_CHANNEL'
'READ_MESSAGE_HISTORY'
'MANAGE_MESSAGES'
:MESSAGE_UPDATE
:CHANNEL_PINS_UPDATE
Examples
iex> Remedy.API.add_pinned_channel_message(43189401384091, 18743893102394)
Specs
publish_message(Remedy.Schema.Message.t()) :: {:error, any()} | {:ok, any()}
Publish a message in a news channel.
This will propagate a message out to all followers of the channel.
This is known as "Crosspost Message" in the Discord API.
Removes a ban for a user.
User to unban is specified by guild_id
and user_id
.
An optional reason
can be specified for the audit log.
Removes a member from a guild.
This event requires the KICK_MEMBERS
permission. It fires a
Remedy.Consumer.guild_member_remove/0
event.
An optional reason can be provided for the audit log with reason
.
If successful, returns {:ok}
. Otherwise, returns a Remedy.API.error/0
.
Examples
iex> Remedy.API.remove_guild_member(1453827904102291, 18739485766253)
{:ok}
Removes a role from a member.
Role to remove is specified by role_id
.
User to remove role from is specified by guild_id
and user_id
.
An optional reason
can be given for the audit log.
Starts a thread.
Triggers the typing indicator.
Unpins a message in a channel.
Permissions
- 'VIEW_CHANNEL'
- 'READ_MESSAGE_HISTORY'
- 'MANAGE_MESSAGES'
Events
:MESSAGE_UPDATE
:CHANNEL_PINS_UPDATE
Examples
iex>