diff --git a/docs/_overwrites/Commands/CommandContext.Overwrite.md b/docs/_overwrites/Commands/CommandContext.Overwrite.md new file mode 100644 index 000000000..fdde3b2e5 --- /dev/null +++ b/docs/_overwrites/Commands/CommandContext.Overwrite.md @@ -0,0 +1,9 @@ +--- +uid: Discord.Commands.CommandContext +--- + +An example of how this class is used the command system can be seen +below: + +[!code[Sample module](../../guides/commands/samples/empty-module.cs)] +[!code[Command handler](../../guides/commands/samples/command_handler.cs)] \ No newline at end of file diff --git a/docs/_overwrites/Commands/SocketCommandContext.Overwrite.md b/docs/_overwrites/Commands/SocketCommandContext.Overwrite.md new file mode 100644 index 000000000..233418201 --- /dev/null +++ b/docs/_overwrites/Commands/SocketCommandContext.Overwrite.md @@ -0,0 +1,9 @@ +--- +uid: Discord.Commands.SocketCommandContext +--- + +An example of how this class is used the command system can be seen +below: + +[!code[Sample module](../../guides/commands/samples/empty-module.cs)] +[!code[Command handler](../../guides/commands/samples/command_handler.cs)] \ No newline at end of file diff --git a/docs/docfx.json b/docs/docfx.json index a1c1ef2f6..cc126b0e1 100644 --- a/docs/docfx.json +++ b/docs/docfx.json @@ -55,6 +55,7 @@ "template":[ "default" ], + "overwrite": "_overwrites/**/**.md", "globalMetadata":{ "_appFooter":"Discord.Net (c) 2015-2018 2.0.0-beta", "_enableSearch":true diff --git a/src/Discord.Net.Commands/Attributes/AliasAttribute.cs b/src/Discord.Net.Commands/Attributes/AliasAttribute.cs index 6cd0abbb7..085a1f307 100644 --- a/src/Discord.Net.Commands/Attributes/AliasAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/AliasAttribute.cs @@ -2,7 +2,7 @@ using System; namespace Discord.Commands { - /// Provides aliases for a command. + /// Marks the aliases for a command. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class AliasAttribute : Attribute { diff --git a/src/Discord.Net.Commands/Attributes/CommandAttribute.cs b/src/Discord.Net.Commands/Attributes/CommandAttribute.cs index eeb43bad3..db1f3067b 100644 --- a/src/Discord.Net.Commands/Attributes/CommandAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/CommandAttribute.cs @@ -2,7 +2,7 @@ using System; namespace Discord.Commands { - /// Provides the execution information for a command. + /// Marks the execution information for a command. [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class CommandAttribute : Attribute { diff --git a/src/Discord.Net.Commands/Attributes/DontAutoLoadAttribute.cs b/src/Discord.Net.Commands/Attributes/DontAutoLoadAttribute.cs index 22664afd1..451b87f5e 100644 --- a/src/Discord.Net.Commands/Attributes/DontAutoLoadAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/DontAutoLoadAttribute.cs @@ -2,7 +2,7 @@ using System; namespace Discord.Commands { - /// Prevents the module from being loaded automatically. + /// Prevents the marked module from being loaded automatically. [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class DontAutoLoadAttribute : Attribute { diff --git a/src/Discord.Net.Commands/Attributes/DontInjectAttribute.cs b/src/Discord.Net.Commands/Attributes/DontInjectAttribute.cs index 354b87364..b0823693e 100644 --- a/src/Discord.Net.Commands/Attributes/DontInjectAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/DontInjectAttribute.cs @@ -2,7 +2,7 @@ using System; namespace Discord.Commands { - /// Prevents the property from being injected into a module. + /// Prevents the marked property from being injected into a module. [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public class DontInjectAttribute : Attribute { } diff --git a/src/Discord.Net.Commands/Attributes/GroupAttribute.cs b/src/Discord.Net.Commands/Attributes/GroupAttribute.cs index b1760d149..d2cc6165f 100644 --- a/src/Discord.Net.Commands/Attributes/GroupAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/GroupAttribute.cs @@ -2,15 +2,19 @@ using System; namespace Discord.Commands { + /// Marks the module as a command group. [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public class GroupAttribute : Attribute { + /// Gets the prefix set for the module. public string Prefix { get; } public GroupAttribute() { Prefix = null; } + /// Creates a with the provided prefix. + /// The prefix of the module group. public GroupAttribute(string prefix) { Prefix = prefix; diff --git a/src/Discord.Net.Commands/Attributes/NameAttribute.cs b/src/Discord.Net.Commands/Attributes/NameAttribute.cs index 4a4b2bfed..b52a2fe71 100644 --- a/src/Discord.Net.Commands/Attributes/NameAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/NameAttribute.cs @@ -3,6 +3,7 @@ using System; namespace Discord.Commands { // Override public name of command/module + /// Marks the public name of a command, module, or parameter. [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] public class NameAttribute : Attribute { diff --git a/src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs b/src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs index 44ab6d214..67d61c8d3 100644 --- a/src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs @@ -4,13 +4,17 @@ using System.Reflection; namespace Discord.Commands { + /// Marks the to be read by the specified . [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] public class OverrideTypeReaderAttribute : Attribute { private static readonly TypeInfo _typeReaderTypeInfo = typeof(TypeReader).GetTypeInfo(); + /// Gets the specified of the parameter. public Type TypeReader { get; } + /// Marks the parameter to be read with the specified . + /// The to be used with the parameter. public OverrideTypeReaderAttribute(Type overridenTypeReader) { if (!_typeReaderTypeInfo.IsAssignableFrom(overridenTypeReader.GetTypeInfo())) diff --git a/src/Discord.Net.Commands/Attributes/ParameterPreconditionAttribute.cs b/src/Discord.Net.Commands/Attributes/ParameterPreconditionAttribute.cs index 3c5e8cf92..e6d244b8f 100644 --- a/src/Discord.Net.Commands/Attributes/ParameterPreconditionAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/ParameterPreconditionAttribute.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; namespace Discord.Commands { + /// Requires the parameter to pass the specified precondition before execution can begin. [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = true, Inherited = true)] public abstract class ParameterPreconditionAttribute : Attribute { diff --git a/src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs b/src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs index 367adebf0..6b6bd8b6e 100644 --- a/src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading.Tasks; namespace Discord.Commands @@ -6,11 +6,13 @@ namespace Discord.Commands [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public abstract class PreconditionAttribute : Attribute { - /// - /// Specify a group that this precondition belongs to. Preconditions of the same group require only one - /// of the preconditions to pass in order to be successful (A || B). Specifying = - /// or not at all will require *all* preconditions to pass, just like normal (A && B). - /// + /// Specify a group that this precondition belongs to. + /// + /// Preconditions of the same group require only one + /// of the preconditions to pass in order to be successful (A || B). + /// Specifying = + /// or not at all will require *all* preconditions to pass, just like normal (A && B). + /// public string Group { get; set; } = null; public abstract Task CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services); diff --git a/src/Discord.Net.Commands/Attributes/RemainderAttribute.cs b/src/Discord.Net.Commands/Attributes/RemainderAttribute.cs index 56938f167..fd1d93d9f 100644 --- a/src/Discord.Net.Commands/Attributes/RemainderAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/RemainderAttribute.cs @@ -2,6 +2,7 @@ using System; namespace Discord.Commands { + /// Marks the input to not be parsed by the parser. [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] public class RemainderAttribute : Attribute { diff --git a/src/Discord.Net.Commands/CommandContext.cs b/src/Discord.Net.Commands/CommandContext.cs index d884d8b29..9e0766a68 100644 --- a/src/Discord.Net.Commands/CommandContext.cs +++ b/src/Discord.Net.Commands/CommandContext.cs @@ -1,5 +1,6 @@ namespace Discord.Commands { + /// The context of a command which may contain the client, user, guild, channel, and message. public class CommandContext : ICommandContext { /// diff --git a/src/Discord.Net.Commands/CommandException.cs b/src/Discord.Net.Commands/CommandException.cs index 1584641b3..335033258 100644 --- a/src/Discord.Net.Commands/CommandException.cs +++ b/src/Discord.Net.Commands/CommandException.cs @@ -2,6 +2,7 @@ using System; namespace Discord.Commands { + /// An exception thrown when a command fails to execute. public class CommandException : Exception { /// The command that caused the exception. diff --git a/src/Discord.Net.Core/Commands/ICommandContext.cs b/src/Discord.Net.Core/Commands/ICommandContext.cs index e0ea18ca8..2df18c748 100644 --- a/src/Discord.Net.Core/Commands/ICommandContext.cs +++ b/src/Discord.Net.Core/Commands/ICommandContext.cs @@ -1,16 +1,17 @@ namespace Discord.Commands { + /// Represents the context of a command. This may include the client, guild, channel, user, and message. public interface ICommandContext { - /// The Discord client of which the command is executed with. + /// Gets the that the command is executed with. IDiscordClient Client { get; } - /// The guild of which the command is executed in. + /// Gets the that the command is executed in. IGuild Guild { get; } - /// The channel of which the command is executed in. + /// Gets the that the command is executed in. IMessageChannel Channel { get; } - /// The user who executed the command. + /// Gets the who executed the command. IUser User { get; } - /// The message of which the command is interpreted from. + /// Gets the that the command is interpreted from. IUserMessage Message { get; } } } diff --git a/src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs b/src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs index c8b0747e7..bac62e81b 100644 --- a/src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs +++ b/src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs @@ -1,15 +1,23 @@ -using Discord.WebSocket; +using Discord.WebSocket; namespace Discord.Commands { + /// The WebSocket variant of , which may contain the client, user, guild, channel, and message. + /// public class SocketCommandContext : ICommandContext { + /// Gets the that the command is executed with. public DiscordSocketClient Client { get; } + /// Gets the that the command is executed in. public SocketGuild Guild { get; } + /// Gets the that the command is executed in. public ISocketMessageChannel Channel { get; } + /// Gets the who executed the command. public SocketUser User { get; } + /// Gets the that the command is interpreted from. public SocketUserMessage Message { get; } + /// Indicates whether the channel that the command is executed in is a private channel. public bool IsPrivate => Channel is IPrivateChannel; public SocketCommandContext(DiscordSocketClient client, SocketUserMessage msg) @@ -22,10 +30,15 @@ namespace Discord.Commands } //ICommandContext + /// IDiscordClient ICommandContext.Client => Client; + /// IGuild ICommandContext.Guild => Guild; + /// IMessageChannel ICommandContext.Channel => Channel; + /// IUser ICommandContext.User => User; + /// IUserMessage ICommandContext.Message => Message; } }