| @@ -8,7 +8,6 @@ namespace Discord.Commands | |||||
| [Flags] | [Flags] | ||||
| public enum ContextType | public enum ContextType | ||||
| { | { | ||||
| Invalid = 0, // 00 | |||||
| Guild = 1, // 01 | Guild = 1, // 01 | ||||
| DM = 2 // 10 | DM = 2 // 10 | ||||
| } | } | ||||
| @@ -22,18 +21,12 @@ namespace Discord.Commands | |||||
| public RequireContextAttribute(ContextType context) | public RequireContextAttribute(ContextType context) | ||||
| { | { | ||||
| Context = context; | Context = context; | ||||
| if (Context == ContextType.Invalid) | |||||
| throw new ArgumentException("Context must be a bitfield of ContextType.Guild and ContextType.DM", "context"); | |||||
| } | } | ||||
| public override Task<PreconditionResult> CheckPermissions(IMessage context, Command executingCommand, object moduleInstance) | public override Task<PreconditionResult> CheckPermissions(IMessage context, Command executingCommand, object moduleInstance) | ||||
| { | { | ||||
| var validContext = false; | var validContext = false; | ||||
| if (Context == ContextType.Invalid) | |||||
| throw new InvalidOperationException("Invalid ContextType"); | |||||
| if (Context.HasFlag(ContextType.Guild)) | if (Context.HasFlag(ContextType.Guild)) | ||||
| validContext = validContext || context.Channel is IGuildChannel; | validContext = validContext || context.Channel is IGuildChannel; | ||||