pub struct HttpClient { /* private fields */ }Expand description
Discord REST API client.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub async fn get_guild_audit_log(
&self,
guild_id: Snowflake,
params: &GetAuditLogParams,
) -> Result<AuditLog<'static>, HttpError>
pub async fn get_guild_audit_log( &self, guild_id: Snowflake, params: &GetAuditLogParams, ) -> Result<AuditLog<'static>, HttpError>
Get guild audit log.
Source§impl HttpClient
impl HttpClient
Sourcepub async fn list_auto_moderation_rules(
&self,
guild_id: Snowflake,
) -> Result<Vec<AutoModRule>, HttpError>
pub async fn list_auto_moderation_rules( &self, guild_id: Snowflake, ) -> Result<Vec<AutoModRule>, HttpError>
List Auto Moderation rules.
Sourcepub async fn get_auto_moderation_rule(
&self,
guild_id: Snowflake,
rule_id: Snowflake,
) -> Result<AutoModRule, HttpError>
pub async fn get_auto_moderation_rule( &self, guild_id: Snowflake, rule_id: Snowflake, ) -> Result<AutoModRule, HttpError>
Get an Auto Moderation rule.
Sourcepub async fn create_auto_moderation_rule(
&self,
guild_id: Snowflake,
params: &CreateAutoModRuleParams,
) -> Result<AutoModRule, HttpError>
pub async fn create_auto_moderation_rule( &self, guild_id: Snowflake, params: &CreateAutoModRuleParams, ) -> Result<AutoModRule, HttpError>
Create an Auto Moderation rule.
Sourcepub async fn modify_auto_moderation_rule(
&self,
guild_id: Snowflake,
rule_id: Snowflake,
params: &ModifyAutoModRuleParams,
) -> Result<AutoModRule, HttpError>
pub async fn modify_auto_moderation_rule( &self, guild_id: Snowflake, rule_id: Snowflake, params: &ModifyAutoModRuleParams, ) -> Result<AutoModRule, HttpError>
Modify an Auto Moderation rule.
Source§impl HttpClient
impl HttpClient
Sourcepub async fn get_channel(
&self,
channel_id: Snowflake,
) -> Result<Channel<'static>, HttpError>
pub async fn get_channel( &self, channel_id: Snowflake, ) -> Result<Channel<'static>, HttpError>
Get a channel.
Sourcepub async fn delete_channel(
&self,
channel_id: Snowflake,
reason: Option<&str>,
) -> Result<Channel<'static>, HttpError>
pub async fn delete_channel( &self, channel_id: Snowflake, reason: Option<&str>, ) -> Result<Channel<'static>, HttpError>
Delete/Close a channel.
Sourcepub async fn create_channel(
&self,
guild_id: Snowflake,
params: &CreateChannel<'_>,
) -> Result<Channel<'static>, HttpError>
pub async fn create_channel( &self, guild_id: Snowflake, params: &CreateChannel<'_>, ) -> Result<Channel<'static>, HttpError>
Create a new channel in a guild.
Sourcepub async fn get_message(
&self,
channel_id: Snowflake,
message_id: Snowflake,
) -> Result<Message<'static>, HttpError>
pub async fn get_message( &self, channel_id: Snowflake, message_id: Snowflake, ) -> Result<Message<'static>, HttpError>
Get a single message.
Sourcepub async fn create_message_struct(
&self,
channel_id: Snowflake,
message: &CreateMessage<'_>,
) -> Result<Message<'static>, HttpError>
pub async fn create_message_struct( &self, channel_id: Snowflake, message: &CreateMessage<'_>, ) -> Result<Message<'static>, HttpError>
Send a message to a channel.
Uses titanium_model::CreateMessage for type-safe building.
Sourcepub async fn send_message(
&self,
channel_id: Snowflake,
content: impl Into<String>,
) -> Result<Message<'static>, HttpError>
pub async fn send_message( &self, channel_id: Snowflake, content: impl Into<String>, ) -> Result<Message<'static>, HttpError>
Send a simple text message (helper).
Sourcepub async fn edit_message(
&self,
channel_id: Snowflake,
message_id: Snowflake,
content: impl Into<String>,
) -> Result<Message<'static>, HttpError>
pub async fn edit_message( &self, channel_id: Snowflake, message_id: Snowflake, content: impl Into<String>, ) -> Result<Message<'static>, HttpError>
Edit a message.
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(token: impl Into<String>) -> Result<Self, HttpError>
pub fn new(token: impl Into<String>) -> Result<Self, HttpError>
Create a new HTTP client with the given bot token.
Sourcepub async fn get_gateway_bot(&self) -> Result<GatewayBotResponse, HttpError>
pub async fn get_gateway_bot(&self) -> Result<GatewayBotResponse, HttpError>
Get gateway bot information.
Returns the recommended number of shards, gateway URL, and session limits. This is essential for large bots to determine sharding configuration.
Sourcepub async fn get_current_user(&self) -> Result<CurrentUser, HttpError>
pub async fn get_current_user(&self) -> Result<CurrentUser, HttpError>
Get the current bot user.
Sourcepub async fn get_current_application(
&self,
) -> Result<CurrentApplication, HttpError>
pub async fn get_current_application( &self, ) -> Result<CurrentApplication, HttpError>
Get the current application.
Sourcepub async fn create_global_application_command(
&self,
application_id: Snowflake,
command: &ApplicationCommand,
) -> Result<ApplicationCommand, HttpError>
pub async fn create_global_application_command( &self, application_id: Snowflake, command: &ApplicationCommand, ) -> Result<ApplicationCommand, HttpError>
Create a global application command.
Sourcepub async fn create_message(
&self,
channel_id: Snowflake,
content: &CreateMessage<'_>,
) -> Result<Message<'static>, HttpError>
pub async fn create_message( &self, channel_id: Snowflake, content: &CreateMessage<'_>, ) -> Result<Message<'static>, HttpError>
Create a message in a channel.
Source§impl HttpClient
impl HttpClient
Sourcepub async fn list_guild_emojis(
&self,
guild_id: Snowflake,
) -> Result<Vec<Emoji<'static>>, HttpError>
pub async fn list_guild_emojis( &self, guild_id: Snowflake, ) -> Result<Vec<Emoji<'static>>, HttpError>
List guild emojis.
Sourcepub async fn get_guild_emoji(
&self,
guild_id: Snowflake,
emoji_id: Snowflake,
) -> Result<Emoji<'static>, HttpError>
pub async fn get_guild_emoji( &self, guild_id: Snowflake, emoji_id: Snowflake, ) -> Result<Emoji<'static>, HttpError>
Get guild emoji.
Sourcepub async fn create_guild_emoji(
&self,
guild_id: Snowflake,
params: &CreateEmojiParams,
) -> Result<Emoji<'static>, HttpError>
pub async fn create_guild_emoji( &self, guild_id: Snowflake, params: &CreateEmojiParams, ) -> Result<Emoji<'static>, HttpError>
Create guild emoji.
Sourcepub async fn modify_guild_emoji(
&self,
guild_id: Snowflake,
emoji_id: Snowflake,
params: &ModifyEmojiParams,
) -> Result<Emoji<'static>, HttpError>
pub async fn modify_guild_emoji( &self, guild_id: Snowflake, emoji_id: Snowflake, params: &ModifyEmojiParams, ) -> Result<Emoji<'static>, HttpError>
Modify guild emoji.
Sourcepub async fn delete_guild_emoji(
&self,
guild_id: Snowflake,
emoji_id: Snowflake,
) -> Result<(), HttpError>
pub async fn delete_guild_emoji( &self, guild_id: Snowflake, emoji_id: Snowflake, ) -> Result<(), HttpError>
Delete guild emoji.
Sourcepub async fn list_guild_stickers(
&self,
guild_id: Snowflake,
) -> Result<Vec<Sticker<'static>>, HttpError>
pub async fn list_guild_stickers( &self, guild_id: Snowflake, ) -> Result<Vec<Sticker<'static>>, HttpError>
List guild stickers.
Sourcepub async fn get_guild_sticker(
&self,
guild_id: Snowflake,
sticker_id: Snowflake,
) -> Result<Sticker<'static>, HttpError>
pub async fn get_guild_sticker( &self, guild_id: Snowflake, sticker_id: Snowflake, ) -> Result<Sticker<'static>, HttpError>
Get guild sticker.
Sourcepub async fn create_guild_sticker(
&self,
guild_id: Snowflake,
params: &CreateStickerParams,
) -> Result<Sticker<'static>, HttpError>
pub async fn create_guild_sticker( &self, guild_id: Snowflake, params: &CreateStickerParams, ) -> Result<Sticker<'static>, HttpError>
Create guild sticker.
Source§impl HttpClient
impl HttpClient
Sourcepub async fn get_member(
&self,
guild_id: Snowflake,
user_id: Snowflake,
) -> Result<GuildMember<'static>, HttpError>
pub async fn get_member( &self, guild_id: Snowflake, user_id: Snowflake, ) -> Result<GuildMember<'static>, HttpError>
Get a guild member.
Sourcepub async fn list_members(
&self,
guild_id: Snowflake,
limit: Option<u32>,
after: Option<Snowflake>,
) -> Result<Vec<GuildMember<'static>>, HttpError>
pub async fn list_members( &self, guild_id: Snowflake, limit: Option<u32>, after: Option<Snowflake>, ) -> Result<Vec<GuildMember<'static>>, HttpError>
List guild members.
query: limit (1-1000), after (user_id)
Sourcepub async fn kick_member(
&self,
guild_id: Snowflake,
user_id: Snowflake,
reason: Option<&str>,
) -> Result<(), HttpError>
pub async fn kick_member( &self, guild_id: Snowflake, user_id: Snowflake, reason: Option<&str>, ) -> Result<(), HttpError>
Kick a member from the guild.
Sourcepub async fn ban_member(
&self,
guild_id: Snowflake,
user_id: Snowflake,
delete_message_seconds: Option<u32>,
reason: Option<&str>,
) -> Result<(), HttpError>
pub async fn ban_member( &self, guild_id: Snowflake, user_id: Snowflake, delete_message_seconds: Option<u32>, reason: Option<&str>, ) -> Result<(), HttpError>
Ban a member from the guild.
delete_message_seconds: Number of seconds to delete messages for (0-604800).
Sourcepub async fn unban_member(
&self,
guild_id: Snowflake,
user_id: Snowflake,
reason: Option<&str>,
) -> Result<(), HttpError>
pub async fn unban_member( &self, guild_id: Snowflake, user_id: Snowflake, reason: Option<&str>, ) -> Result<(), HttpError>
Unban a member.
Sourcepub async fn modify_member(
&self,
guild_id: Snowflake,
user_id: Snowflake,
params: &ModifyMember<'_>,
) -> Result<GuildMember<'static>, HttpError>
pub async fn modify_member( &self, guild_id: Snowflake, user_id: Snowflake, params: &ModifyMember<'_>, ) -> Result<GuildMember<'static>, HttpError>
Modify a guild member (mute, deafen, roles, nick).
Sourcepub async fn get_roles(
&self,
guild_id: Snowflake,
) -> Result<Vec<Role<'static>>, HttpError>
pub async fn get_roles( &self, guild_id: Snowflake, ) -> Result<Vec<Role<'static>>, HttpError>
Get all roles.
Sourcepub async fn create_role(
&self,
guild_id: Snowflake,
params: &CreateRole<'_>,
) -> Result<Role<'static>, HttpError>
pub async fn create_role( &self, guild_id: Snowflake, params: &CreateRole<'_>, ) -> Result<Role<'static>, HttpError>
Create a new role.
Source§impl HttpClient
impl HttpClient
Sourcepub async fn create_interaction_response(
&self,
interaction_id: Snowflake,
token: &str,
response: &InteractionResponse<'_>,
) -> Result<(), HttpError>
pub async fn create_interaction_response( &self, interaction_id: Snowflake, token: &str, response: &InteractionResponse<'_>, ) -> Result<(), HttpError>
Create a response to an Interaction.
This is the initial response to an interaction (Slash Command, Button, etc.).
You must respond within 3 seconds, or use InteractionCallbackType::DeferredChannelMessageWithSource.
Sourcepub async fn get_original_interaction_response(
&self,
application_id: Snowflake,
token: &str,
) -> Result<Message<'static>, HttpError>
pub async fn get_original_interaction_response( &self, application_id: Snowflake, token: &str, ) -> Result<Message<'static>, HttpError>
Get the original response message.
Sourcepub async fn edit_original_interaction_response<B: Serialize>(
&self,
application_id: Snowflake,
token: &str,
body: B,
) -> Result<Message<'static>, HttpError>
pub async fn edit_original_interaction_response<B: Serialize>( &self, application_id: Snowflake, token: &str, body: B, ) -> Result<Message<'static>, HttpError>
Edit the original response message.
This is used to update the message after a DEFER response.
Source§impl HttpClient
impl HttpClient
Sourcepub async fn list_skus(
&self,
application_id: Snowflake,
) -> Result<Vec<Sku>, HttpError>
pub async fn list_skus( &self, application_id: Snowflake, ) -> Result<Vec<Sku>, HttpError>
List SKUs for an application.
Sourcepub async fn list_entitlements(
&self,
application_id: Snowflake,
query: Option<&Value>,
) -> Result<Vec<Entitlement>, HttpError>
pub async fn list_entitlements( &self, application_id: Snowflake, query: Option<&Value>, ) -> Result<Vec<Entitlement>, HttpError>
List entitlements for an application.
Sourcepub async fn get_entitlement(
&self,
application_id: Snowflake,
entitlement_id: Snowflake,
) -> Result<Entitlement, HttpError>
pub async fn get_entitlement( &self, application_id: Snowflake, entitlement_id: Snowflake, ) -> Result<Entitlement, HttpError>
Get an entitlement.
Sourcepub async fn create_test_entitlement(
&self,
application_id: Snowflake,
payload: &Value,
) -> Result<Entitlement, HttpError>
pub async fn create_test_entitlement( &self, application_id: Snowflake, payload: &Value, ) -> Result<Entitlement, HttpError>
Create a test entitlement.
Source§impl HttpClient
impl HttpClient
Sourcepub async fn list_guild_soundboard_sounds(
&self,
guild_id: Snowflake,
) -> Result<Vec<SoundboardSound<'static>>, HttpError>
pub async fn list_guild_soundboard_sounds( &self, guild_id: Snowflake, ) -> Result<Vec<SoundboardSound<'static>>, HttpError>
List soundboard sounds for a guild.
Sourcepub async fn get_guild_soundboard_sound(
&self,
guild_id: Snowflake,
sound_id: Snowflake,
) -> Result<SoundboardSound<'static>, HttpError>
pub async fn get_guild_soundboard_sound( &self, guild_id: Snowflake, sound_id: Snowflake, ) -> Result<SoundboardSound<'static>, HttpError>
Get a specific soundboard sound.
Sourcepub async fn create_guild_soundboard_sound(
&self,
guild_id: Snowflake,
payload: &Value,
) -> Result<SoundboardSound<'static>, HttpError>
pub async fn create_guild_soundboard_sound( &self, guild_id: Snowflake, payload: &Value, ) -> Result<SoundboardSound<'static>, HttpError>
Create a soundboard sound.
Payload should contain name, sound (base64), and optional volume, emoji_id, emoji_name.
Sourcepub async fn modify_guild_soundboard_sound(
&self,
guild_id: Snowflake,
sound_id: Snowflake,
payload: &Value,
) -> Result<SoundboardSound<'static>, HttpError>
pub async fn modify_guild_soundboard_sound( &self, guild_id: Snowflake, sound_id: Snowflake, payload: &Value, ) -> Result<SoundboardSound<'static>, HttpError>
Modify a soundboard sound.
Source§impl HttpClient
impl HttpClient
Sourcepub async fn create_webhook(
&self,
channel_id: Snowflake,
name: &str,
avatar: Option<&str>,
) -> Result<Webhook<'static>, HttpError>
pub async fn create_webhook( &self, channel_id: Snowflake, name: &str, avatar: Option<&str>, ) -> Result<Webhook<'static>, HttpError>
Create a webhook.
Sourcepub async fn get_channel_webhooks(
&self,
channel_id: Snowflake,
) -> Result<Vec<Webhook<'static>>, HttpError>
pub async fn get_channel_webhooks( &self, channel_id: Snowflake, ) -> Result<Vec<Webhook<'static>>, HttpError>
Get channel webhooks.
Sourcepub async fn get_guild_webhooks(
&self,
guild_id: Snowflake,
) -> Result<Vec<Webhook<'static>>, HttpError>
pub async fn get_guild_webhooks( &self, guild_id: Snowflake, ) -> Result<Vec<Webhook<'static>>, HttpError>
Get guild webhooks.
Sourcepub async fn execute_webhook(
&self,
webhook_id: Snowflake,
webhook_token: &str,
params: &ExecuteWebhook,
) -> Result<Option<Message<'static>>, HttpError>
pub async fn execute_webhook( &self, webhook_id: Snowflake, webhook_token: &str, params: &ExecuteWebhook, ) -> Result<Option<Message<'static>>, HttpError>
Execute webhook (send message).
Note: Webhooks can be executed without a bot token if usage via id/token url.
This method complies with the library structure using the client’s auth or just payload.