Ignore messages from self
This commit is contained in:
parent
1914ee2ee8
commit
871c239ef2
1 changed files with 6 additions and 5 deletions
|
@ -13,7 +13,7 @@ const COMMAND_PREFIX: &str = "!";
|
|||
struct Discord {
|
||||
discord: discord::Discord,
|
||||
connection: Option<Arc<Mutex<discord::Connection>>>,
|
||||
me: Option<discord::model::CurrentUser>,
|
||||
current_user: Option<discord::model::CurrentUser>,
|
||||
}
|
||||
|
||||
impl Discord {
|
||||
|
@ -23,7 +23,7 @@ impl Discord {
|
|||
Ok(Self {
|
||||
discord,
|
||||
connection: None,
|
||||
me: None,
|
||||
current_user: None,
|
||||
})
|
||||
} else {
|
||||
return Err(eyre!("discord configuration was empty"));
|
||||
|
@ -36,7 +36,8 @@ impl Discord {
|
|||
}
|
||||
let (connection, ready_ev) = self.discord.connect()?;
|
||||
self.connection = Some(Arc::new(Mutex::new(connection)));
|
||||
self.me = self.discord.get_current_user().ok();
|
||||
self.current_user = self.discord.get_current_user().ok();
|
||||
info!("Discord current user: {:?}", self.current_user);
|
||||
Ok(ready_ev)
|
||||
}
|
||||
|
||||
|
@ -195,8 +196,8 @@ impl Discord {
|
|||
}
|
||||
|
||||
pub fn handle_message(&self, msg: Message) -> Result<()> {
|
||||
if let Some(me) = &self.me {
|
||||
if msg.author.id == me.id {
|
||||
if let Some(current_user) = &self.current_user {
|
||||
if msg.author.id == current_user.id {
|
||||
trace!("Ignoring message from self");
|
||||
}
|
||||
return Ok(());
|
||||
|
|
Loading…
Reference in a new issue