diff options
author | Ashelyn Rose <git@ashen.earth> | 2024-10-06 17:17:35 -0600 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-10-06 17:17:35 -0600 |
commit | 4ceb1c233d48bc537a8d2aaad129abbf71d8ff81 (patch) | |
tree | 88485339cad76024c03d57a09cc00b94ba355482 /src/system/bot | |
parent | ec104a719f46d6812661c29355e7a9fea8418b49 (diff) |
Fetches target message from API when not in cache
Diffstat (limited to 'src/system/bot')
-rw-r--r-- | src/system/bot/client.rs | 12 | ||||
-rw-r--r-- | src/system/bot/mod.rs | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/system/bot/client.rs b/src/system/bot/client.rs index 4d4f7bb..a2d1b28 100644 --- a/src/system/bot/client.rs +++ b/src/system/bot/client.rs @@ -35,6 +35,18 @@ impl Client { .expect("Could not deserialize message") } + pub async fn fetch_recent_channel_messages(&self, channel_id: ChannelId) -> Result<Vec<FullMessage>, TwiError> { + let client = self.client.lock().await; + + Ok(client + .channel_messages(channel_id) + .limit(10).unwrap() + .await? + .model() + .await + .unwrap()) + } + pub async fn resend_message(&self, message_id: MessageId, channel_id: ChannelId) { let bot_conf = self.bot_conf.read().await; let message = self.fetch_message(message_id, channel_id).await; diff --git a/src/system/bot/mod.rs b/src/system/bot/mod.rs index f0a2e45..2aa3e0a 100644 --- a/src/system/bot/mod.rs +++ b/src/system/bot/mod.rs @@ -70,6 +70,10 @@ impl Bot { self.client.fetch_message(message_id, channel_id).await } + pub async fn fetch_recent_channel_messages(&self, channel_id: ChannelId) -> Result<Vec<FullMessage>, TwiError> { + self.client.fetch_recent_channel_messages(channel_id).await + } + pub async fn resend_message(&self, message_id: MessageId, channel_id: ChannelId) { self.client.resend_message(message_id, channel_id).await; } |