twilight_webhook/
util.rs

1use twilight_http::request::channel::webhook::ExecuteWebhook;
2use twilight_model::channel::Channel;
3
4/// Utility functions to execute webhooks
5pub trait ExecuteWebhookExt {
6    /// If the channel is a thread channel, execute the webhook in it
7    #[must_use]
8    fn in_channel(self, channel: &Channel) -> Self;
9}
10
11impl ExecuteWebhookExt for ExecuteWebhook<'_> {
12    fn in_channel(self, channel: &Channel) -> Self {
13        if channel.kind.is_thread() {
14            self.thread_id(channel.id)
15        } else {
16            self
17        }
18    }
19}