Skip to content

Commit 71abc63

Browse files
authored
Merge pull request #69 from rust-lang/fix-edit-reactivity
only attempt to edit messages that start with prefix
2 parents 6aae0cc + 1881c88 commit 71abc63

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use reqwest::blocking::Client as HttpClient;
77
use serenity::{model::channel::Message, prelude::Context};
88
use std::{collections::HashMap, sync::Arc};
99

10-
const PREFIX: &'static str = "?";
10+
pub(crate) const PREFIX: &'static str = "?";
1111
pub(crate) type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
1212
pub(crate) type GuardFn = fn(&Args) -> Result<bool>;
1313

src/main.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,14 @@ impl EventHandler for Events {
266266
.content(ev.content.unwrap_or_else(|| String::new()));
267267

268268
let msg = msg.build();
269-
info!(
270-
"sending edited message - {:?} {:?}",
271-
msg.content, msg.author
272-
);
273-
self.cmds.execute(cx, &msg);
269+
270+
if msg.content.starts_with(commands::PREFIX) {
271+
info!(
272+
"sending edited message - {:?} {:?}",
273+
msg.content, msg.author
274+
);
275+
self.cmds.execute(cx, &msg);
276+
}
274277
}
275278
}
276279

0 commit comments

Comments
 (0)