From ad0d4752f7279ac44680ca19fca04437f6cb9d48 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Tue, 22 Aug 2023 17:56:13 +0200 Subject: [PATCH] Move search_messages to Channel impl --- src/api/channels/messages.rs | 40 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/api/channels/messages.rs b/src/api/channels/messages.rs index 833ff16..faf6b57 100644 --- a/src/api/channels/messages.rs +++ b/src/api/channels/messages.rs @@ -8,7 +8,7 @@ use crate::errors::{ChorusError, ChorusResult}; use crate::instance::UserMeta; use crate::ratelimiter::ChorusRequest; use crate::types::{ - Message, MessageSearchEndpoint, MessageSearchQuery, MessageSendSchema, Snowflake, + Channel, Message, MessageSearchEndpoint, MessageSearchQuery, MessageSendSchema, Snowflake, }; impl Message { @@ -128,24 +128,6 @@ impl Message { ), }) } - - /// Returns messages without the reactions key that match a search query in the channel. - /// The messages that are direct results will have an extra hit key set to true. - /// If operating on a guild channel, this endpoint requires the `READ_MESSAGE_HISTORY` - /// permission to be present on the current user. - /// - /// If the guild/channel you are searching is not yet indexed, the endpoint will return a 202 accepted response. - /// In this case, the method will return a [`ChorusError::InvalidResponse`] error. - /// - /// # Reference: - /// See - pub async fn search_messages( - channel_id: Snowflake, - query: MessageSearchQuery, - user: &mut UserMeta, - ) -> ChorusResult> { - Message::search(MessageSearchEndpoint::Channel(channel_id), query, user).await - } } fn search_error(result_text: String) -> ChorusError { @@ -174,3 +156,23 @@ impl UserMeta { Message::send(self, channel_id, message).await } } + +impl Channel { + /// Returns messages without the reactions key that match a search query in the channel. + /// The messages that are direct results will have an extra hit key set to true. + /// If operating on a guild channel, this endpoint requires the `READ_MESSAGE_HISTORY` + /// permission to be present on the current user. + /// + /// If the guild/channel you are searching is not yet indexed, the endpoint will return a 202 accepted response. + /// In this case, the method will return a [`ChorusError::InvalidResponse`] error. + /// + /// # Reference: + /// See + pub async fn search_messages( + channel_id: Snowflake, + query: MessageSearchQuery, + user: &mut UserMeta, + ) -> ChorusResult> { + Message::search(MessageSearchEndpoint::Channel(channel_id), query, user).await + } +}