diff --git a/src/main.rs b/src/main.rs index 41dba1e..504fcb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,17 +88,24 @@ impl EventHandler for Handler { // Event handlers are dispatched through multi-threading, and so multiple // of a single event can be dispatched simultaneously. fn on_message(&self, _: Context, msg: Message) { + if msg.author.name == "WynnBot" { + return; + } let cfg = Config::generate().unwrap(); let prefix = cfg.prefix; let connection = commands::establish_connection(); - let prefix = prefixes::table + let mut prefix = prefixes::table .select(prefixes::prefix) .filter(prefixes::id.eq(msg.guild_id().unwrap_or(GuildId(0)).0 as i64)) .load::(&connection) .expect("Error loading prefix").get(0) .map(|x| x.to_owned()) .unwrap_or(prefix); + + if msg.is_private() { + prefix = String::new(); + } if let Err(error) = self.process_message(&msg, &prefix) { //eprintln!("Error: {}", error); @@ -117,6 +124,9 @@ impl EventHandler for Handler { Channel::Guild(channel) => { channel.read().unwrap().guild_id.get().unwrap().name }, + Channel::Private(_) => { + "DM".to_owned() + }, _ => unimplemented!() }, msg.channel_id.get().unwrap(), msg.author, command))); }