Respond to DMs
This commit is contained in:
parent
5e6b32e1db
commit
7629beddcb
12
src/main.rs
12
src/main.rs
@ -88,11 +88,14 @@ 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::<String>(&connection)
|
||||
@ -100,6 +103,10 @@ impl EventHandler for Handler {
|
||||
.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);
|
||||
let _ = msg.channel_id.say(format!("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)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user