diff options
author | Ashelyn Rose <git@ashen.earth> | 2024-10-06 15:25:01 -0600 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-10-06 15:25:01 -0600 |
commit | ec104a719f46d6812661c29355e7a9fea8418b49 (patch) | |
tree | 378eadd6183f5c9af997e52f89bdfa59570b0f7a /src/system/mod.rs | |
parent | 9e15bb9103ba054fa88501cbff2d5e121ffa8544 (diff) |
Actually carries out !edit and !s commands
Diffstat (limited to 'src/system/mod.rs')
-rw-r--r-- | src/system/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/system/mod.rs b/src/system/mod.rs index 6c4d95f..b5cd1ab 100644 --- a/src/system/mod.rs +++ b/src/system/mod.rs @@ -206,6 +206,22 @@ impl Manager { } }, + message_parser::ParsedMessage::Command(Command::Edit(member_id, message_id, new_content)) => { + let bot = self.bots.get(&member_id).unwrap(); + + if let Ok(new_message) = bot.edit_message(message.channel_id, message_id, new_content).await { + + // If we just edited the most recently sent message in this channel, update + // cache for future edit commands + if self.send_cache.get(&new_message.channel_id).map_or(MessageId::new(1u64), |m| m.id) == message_id { + self.send_cache.put(new_message.channel_id, new_message); + } + + // Delete the command message + let _ = bot.delete_message(message.channel_id, message.id).await; + } + } + message_parser::ParsedMessage::Command(Command::UnknownCommand) => { let member_id = if let Some((member_id, _)) = self.latch_state { member_id |