pub struct WebhookManager<'a, B: Backend> { /* private fields */ }Expand description
Webhooks, by ID (D-237). Returned by Context::webhooks.
The cache does not keep webhooks, so the djs-model Webhook is returned;
the messages a webhook sends are cached like the bot’s own. The methods taking a
token use the webhook’s token instead of the bot’s (and work for webhooks of other
applications); the others need MANAGE_WEBHOOKS. For a webhook without a bot, see
WebhookClient.
discord.js counterpart: TextChannel#createWebhook / #fetchWebhooks,
Guild#fetchWebhooks, Client#fetchWebhook and the Webhook methods.
Implementations§
Source§impl<'a, B: Backend> WebhookManager<'a, B>
impl<'a, B: Backend> WebhookManager<'a, B>
Sourcepub fn fetch(
self,
webhook_id: WebhookId,
) -> Fetch<Webhook, impl Future<Output = Result<Webhook, Error>> + Send + 'a>
pub fn fetch( self, webhook_id: WebhookId, ) -> Fetch<Webhook, impl Future<Output = Result<Webhook, Error>> + Send + 'a>
A webhook (Get Webhook).
discord.js counterpart: Client#fetchWebhook(id).
§Errors
Returns the REST error if the request failed.
Sourcepub async fn fetch_with_token(
self,
webhook_id: WebhookId,
token: &str,
) -> Result<Webhook, Error>
pub async fn fetch_with_token( self, webhook_id: WebhookId, token: &str, ) -> Result<Webhook, Error>
A webhook, authorized by its token (Get Webhook with Token).
discord.js counterpart: Client#fetchWebhook(id, token).
§Errors
Returns the REST error if the request failed.
Sourcepub async fn create(
self,
channel_id: ChannelId,
body: &CreateWebhook,
reason: Option<&str>,
) -> Result<Webhook, Error>
pub async fn create( self, channel_id: ChannelId, body: &CreateWebhook, reason: Option<&str>, ) -> Result<Webhook, Error>
Creates a webhook in a channel (Create Webhook).
discord.js counterpart: TextChannel#createWebhook.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn list_channel(
self,
channel_id: ChannelId,
) -> Result<Collection<WebhookId, Webhook>, Error>
pub async fn list_channel( self, channel_id: ChannelId, ) -> Result<Collection<WebhookId, Webhook>, Error>
The webhooks of a channel (Get Channel Webhooks).
discord.js counterpart: TextChannel#fetchWebhooks.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn list_guild(
self,
guild_id: GuildId,
) -> Result<Collection<WebhookId, Webhook>, Error>
pub async fn list_guild( self, guild_id: GuildId, ) -> Result<Collection<WebhookId, Webhook>, Error>
The webhooks of a guild (Get Guild Webhooks).
discord.js counterpart: Guild#fetchWebhooks.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn edit(
self,
webhook_id: WebhookId,
body: &ModifyWebhook,
reason: Option<&str>,
) -> Result<Webhook, Error>
pub async fn edit( self, webhook_id: WebhookId, body: &ModifyWebhook, reason: Option<&str>, ) -> Result<Webhook, Error>
Edits a webhook: its name, avatar or channel (Modify Webhook).
discord.js counterpart: Webhook#edit.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn delete(
self,
webhook_id: WebhookId,
reason: Option<&str>,
) -> Result<(), Error>
pub async fn delete( self, webhook_id: WebhookId, reason: Option<&str>, ) -> Result<(), Error>
Deletes a webhook (Delete Webhook).
discord.js counterpart: Webhook#delete.
§Errors
Returns the REST error if the request failed.
Sourcepub fn send<'t>(
self,
webhook_id: WebhookId,
token: &'t str,
body: impl Into<ExecuteWebhook>,
) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send + 'twhere
'a: 't,
pub fn send<'t>(
self,
webhook_id: WebhookId,
token: &'t str,
body: impl Into<ExecuteWebhook>,
) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send + 'twhere
'a: 't,
Sends a message through a webhook (Execute Webhook,
waiting for the message); accepts anything that converts into an ExecuteWebhook,
such as &str. The message is cached.
discord.js counterpart: Webhook#send.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn fetch_message(
self,
webhook_id: WebhookId,
token: &str,
message_id: MessageId,
thread: Option<ChannelId>,
) -> Result<Arc<CachedMessage>, Error>
pub async fn fetch_message( self, webhook_id: WebhookId, token: &str, message_id: MessageId, thread: Option<ChannelId>, ) -> Result<Arc<CachedMessage>, Error>
A message the webhook sent (Get Webhook Message;
thread for one in a thread); it is cached.
discord.js counterpart: Webhook#fetchMessage.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn edit_message(
self,
webhook_id: WebhookId,
token: &str,
message_id: MessageId,
body: &EditWebhookMessage,
) -> Result<Arc<CachedMessage>, Error>
pub async fn edit_message( self, webhook_id: WebhookId, token: &str, message_id: MessageId, body: &EditWebhookMessage, ) -> Result<Arc<CachedMessage>, Error>
Edits a message the webhook sent (Edit Webhook Message); the result is cached.
discord.js counterpart: Webhook#editMessage.
§Errors
Returns the REST error if the request failed.
Sourcepub async fn delete_message(
self,
webhook_id: WebhookId,
token: &str,
message_id: MessageId,
thread: Option<ChannelId>,
) -> Result<(), Error>
pub async fn delete_message( self, webhook_id: WebhookId, token: &str, message_id: MessageId, thread: Option<ChannelId>, ) -> Result<(), Error>
Deletes a message the webhook sent (Delete Webhook
Message; thread for one in a thread).
discord.js counterpart: Webhook#deleteMessage.
§Errors
Returns the REST error if the request failed.
Trait Implementations§
Source§impl<B: Backend> Clone for WebhookManager<'_, B>
impl<B: Backend> Clone for WebhookManager<'_, B>
impl<B: Backend> Copy for WebhookManager<'_, B>
Auto Trait Implementations§
impl<'a, B> !RefUnwindSafe for WebhookManager<'a, B>
impl<'a, B> !UnwindSafe for WebhookManager<'a, B>
impl<'a, B> Freeze for WebhookManager<'a, B>
impl<'a, B> Send for WebhookManager<'a, B>
impl<'a, B> Sync for WebhookManager<'a, B>
impl<'a, B> Unpin for WebhookManager<'a, B>
impl<'a, B> UnsafeUnpin for WebhookManager<'a, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more