diff options
| author | acdenisSK <[email protected]> | 2018-07-14 11:02:43 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2018-07-14 11:04:39 +0200 |
| commit | 10bbffe9332edf8b8835d98cfffb8ec411162145 (patch) | |
| tree | 6339c47029989f408f9dd1a92629d5e132065875 /src/framework/standard/command.rs | |
| parent | Add docs for `Args::new` (diff) | |
| download | serenity-10bbffe9332edf8b8835d98cfffb8ec411162145.tar.xz serenity-10bbffe9332edf8b8835d98cfffb8ec411162145.zip | |
Allow for nil prefixes in DMs
Fixes #339
Diffstat (limited to 'src/framework/standard/command.rs')
| -rw-r--r-- | src/framework/standard/command.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs index 0fa51f9..f164141 100644 --- a/src/framework/standard/command.rs +++ b/src/framework/standard/command.rs @@ -1,6 +1,9 @@ use client::Context; use model::{ - channel::Message, + channel::{ + Message, + Channel, + }, Permissions }; use std::{ @@ -353,6 +356,20 @@ pub fn positions(ctx: &mut Context, msg: &Message, conf: &Configuration) -> Opti } } + #[cfg(feature = "cache")] + { + let private = match msg.channel() { + Some(Channel::Private(_)) => true, + _ => false, + }; + + // If the above do not fill `positions`, then that means no kind of prefix was present. + // Check if a no-prefix-execution is applicable. + if conf.no_prefix && private && positions.is_empty() { + positions.push(0); + } + } + if positions.is_empty() { return None; } |