Browse Source

Add XMLDocs

+ This commit also adds overwrites for CommandContexts; this allows for additional remarks for the class.
pull/988/head
Hsu Still 7 years ago
parent
commit
3a10820c84
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
17 changed files with 64 additions and 16 deletions
  1. +9
    -0
      docs/_overwrites/Commands/CommandContext.Overwrite.md
  2. +9
    -0
      docs/_overwrites/Commands/SocketCommandContext.Overwrite.md
  3. +1
    -0
      docs/docfx.json
  4. +1
    -1
      src/Discord.Net.Commands/Attributes/AliasAttribute.cs
  5. +1
    -1
      src/Discord.Net.Commands/Attributes/CommandAttribute.cs
  6. +1
    -1
      src/Discord.Net.Commands/Attributes/DontAutoLoadAttribute.cs
  7. +1
    -1
      src/Discord.Net.Commands/Attributes/DontInjectAttribute.cs
  8. +4
    -0
      src/Discord.Net.Commands/Attributes/GroupAttribute.cs
  9. +1
    -0
      src/Discord.Net.Commands/Attributes/NameAttribute.cs
  10. +4
    -0
      src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs
  11. +1
    -0
      src/Discord.Net.Commands/Attributes/ParameterPreconditionAttribute.cs
  12. +8
    -6
      src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs
  13. +1
    -0
      src/Discord.Net.Commands/Attributes/RemainderAttribute.cs
  14. +1
    -0
      src/Discord.Net.Commands/CommandContext.cs
  15. +1
    -0
      src/Discord.Net.Commands/CommandException.cs
  16. +6
    -5
      src/Discord.Net.Core/Commands/ICommandContext.cs
  17. +14
    -1
      src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs

+ 9
- 0
docs/_overwrites/Commands/CommandContext.Overwrite.md View File

@@ -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)]

+ 9
- 0
docs/_overwrites/Commands/SocketCommandContext.Overwrite.md View File

@@ -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)]

+ 1
- 0
docs/docfx.json View File

@@ -55,6 +55,7 @@
"template":[
"default"
],
"overwrite": "_overwrites/**/**.md",
"globalMetadata":{
"_appFooter":"Discord.Net (c) 2015-2018 2.0.0-beta",
"_enableSearch":true


+ 1
- 1
src/Discord.Net.Commands/Attributes/AliasAttribute.cs View File

@@ -2,7 +2,7 @@ using System;

namespace Discord.Commands
{
/// <summary> Provides aliases for a command. </summary>
/// <summary> Marks the aliases for a command. </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class AliasAttribute : Attribute
{


+ 1
- 1
src/Discord.Net.Commands/Attributes/CommandAttribute.cs View File

@@ -2,7 +2,7 @@ using System;

namespace Discord.Commands
{
/// <summary> Provides the execution information for a command. </summary>
/// <summary> Marks the execution information for a command. </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class CommandAttribute : Attribute
{


+ 1
- 1
src/Discord.Net.Commands/Attributes/DontAutoLoadAttribute.cs View File

@@ -2,7 +2,7 @@ using System;

namespace Discord.Commands
{
/// <summary> Prevents the module from being loaded automatically. </summary>
/// <summary> Prevents the marked module from being loaded automatically. </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class DontAutoLoadAttribute : Attribute
{


+ 1
- 1
src/Discord.Net.Commands/Attributes/DontInjectAttribute.cs View File

@@ -2,7 +2,7 @@ using System;

namespace Discord.Commands {

/// <summary> Prevents the property from being injected into a module. </summary>
/// <summary> Prevents the marked property from being injected into a module. </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class DontInjectAttribute : Attribute {
}


+ 4
- 0
src/Discord.Net.Commands/Attributes/GroupAttribute.cs View File

@@ -2,15 +2,19 @@ using System;

namespace Discord.Commands
{
/// <summary> Marks the module as a command group. </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class GroupAttribute : Attribute
{
/// <summary> Gets the prefix set for the module. </summary>
public string Prefix { get; }

public GroupAttribute()
{
Prefix = null;
}
/// <summary> Creates a <see cref="GroupAttribute"/> with the provided prefix. </summary>
/// <param name="prefix"> The prefix of the module group.</param>
public GroupAttribute(string prefix)
{
Prefix = prefix;


+ 1
- 0
src/Discord.Net.Commands/Attributes/NameAttribute.cs View File

@@ -3,6 +3,7 @@ using System;
namespace Discord.Commands
{
// Override public name of command/module
/// <summary> Marks the public name of a command, module, or parameter. </summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public class NameAttribute : Attribute
{


+ 4
- 0
src/Discord.Net.Commands/Attributes/OverrideTypeReaderAttribute.cs View File

@@ -4,13 +4,17 @@ using System.Reflection;

namespace Discord.Commands
{
/// <summary> Marks the <see cref="Type"/> to be read by the specified <see cref="TypeReader"/>. </summary>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public class OverrideTypeReaderAttribute : Attribute
{
private static readonly TypeInfo _typeReaderTypeInfo = typeof(TypeReader).GetTypeInfo();

/// <summary> Gets the specified <see cref="TypeReader"/> of the parameter. </summary>
public Type TypeReader { get; }

/// <summary> Marks the parameter to be read with the specified <see cref="TypeReader"/>. </summary>
/// <param name="overridenTypeReader">The <see cref="TypeReader"/> to be used with the parameter. </param>
public OverrideTypeReaderAttribute(Type overridenTypeReader)
{
if (!_typeReaderTypeInfo.IsAssignableFrom(overridenTypeReader.GetTypeInfo()))


+ 1
- 0
src/Discord.Net.Commands/Attributes/ParameterPreconditionAttribute.cs View File

@@ -3,6 +3,7 @@ using System.Threading.Tasks;

namespace Discord.Commands
{
/// <summary> Requires the parameter to pass the specified precondition before execution can begin. </summary>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = true, Inherited = true)]
public abstract class ParameterPreconditionAttribute : Attribute
{


+ 8
- 6
src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs View File

@@ -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
{
/// <summary>
/// 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 <see cref="Group"/> = <see langword="null"/>
/// or not at all will require *all* preconditions to pass, just like normal (A &amp;&amp; B).
/// </summary>
/// <summary> Specify a group that this precondition belongs to. </summary>
/// <remarks>
/// Preconditions of the same group require only one
/// of the preconditions to pass in order to be successful (A || B).
/// Specifying <see cref="Group"/> = <see langword="null"/>
/// or not at all will require *all* preconditions to pass, just like normal (A &amp;&amp; B).
/// </remarks>
public string Group { get; set; } = null;

public abstract Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services);


+ 1
- 0
src/Discord.Net.Commands/Attributes/RemainderAttribute.cs View File

@@ -2,6 +2,7 @@ using System;

namespace Discord.Commands
{
/// <summary> Marks the input to not be parsed by the parser. </summary>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public class RemainderAttribute : Attribute
{


+ 1
- 0
src/Discord.Net.Commands/CommandContext.cs View File

@@ -1,5 +1,6 @@
namespace Discord.Commands
{
/// <summary> The context of a command which may contain the client, user, guild, channel, and message. </summary>
public class CommandContext : ICommandContext
{
/// <inheritdoc/>


+ 1
- 0
src/Discord.Net.Commands/CommandException.cs View File

@@ -2,6 +2,7 @@ using System;

namespace Discord.Commands
{
/// <summary> An exception thrown when a command fails to execute. </summary>
public class CommandException : Exception
{
/// <summary> The command that caused the exception. </summary>


+ 6
- 5
src/Discord.Net.Core/Commands/ICommandContext.cs View File

@@ -1,16 +1,17 @@
namespace Discord.Commands
{
/// <summary> Represents the context of a command. This may include the client, guild, channel, user, and message. </summary>
public interface ICommandContext
{
/// <summary> The Discord client of which the command is executed with. </summary>
/// <summary> Gets the <see cref="IDiscordClient"/> that the command is executed with. </summary>
IDiscordClient Client { get; }
/// <summary> The guild of which the command is executed in. </summary>
/// <summary> Gets the <see cref="IGuild"/> that the command is executed in. </summary>
IGuild Guild { get; }
/// <summary> The channel of which the command is executed in. </summary>
/// <summary> Gets the <see cref="IMessageChannel"/> that the command is executed in. </summary>
IMessageChannel Channel { get; }
/// <summary> The user who executed the command. </summary>
/// <summary> Gets the <see cref="IUser"/> who executed the command. </summary>
IUser User { get; }
/// <summary> The message of which the command is interpreted from. </summary>
/// <summary> Gets the <see cref="IUserMessage"/> that the command is interpreted from. </summary>
IUserMessage Message { get; }
}
}

+ 14
- 1
src/Discord.Net.WebSocket/Commands/SocketCommandContext.cs View File

@@ -1,15 +1,23 @@
using Discord.WebSocket;
using Discord.WebSocket;

namespace Discord.Commands
{
/// <summary> The WebSocket variant of <see cref="ICommandContext"/>, which may contain the client, user, guild, channel, and message. </summary>
/// <seealso cref="ICommandContext"/>
public class SocketCommandContext : ICommandContext
{
/// <summary> Gets the <see cref="DiscordSocketClient"/> that the command is executed with. </summary>
public DiscordSocketClient Client { get; }
/// <summary> Gets the <see cref="SocketGuild"/> that the command is executed in. </summary>
public SocketGuild Guild { get; }
/// <summary> Gets the <see cref="ISocketMessageChannel"/> that the command is executed in. </summary>
public ISocketMessageChannel Channel { get; }
/// <summary> Gets the <see cref="SocketUser"/> who executed the command. </summary>
public SocketUser User { get; }
/// <summary> Gets the <see cref="SocketUserMessage"/> that the command is interpreted from. </summary>
public SocketUserMessage Message { get; }

/// <summary> Indicates whether the channel that the command is executed in is a private channel. </summary>
public bool IsPrivate => Channel is IPrivateChannel;

public SocketCommandContext(DiscordSocketClient client, SocketUserMessage msg)
@@ -22,10 +30,15 @@ namespace Discord.Commands
}

//ICommandContext
/// <inheritdoc/>
IDiscordClient ICommandContext.Client => Client;
/// <inheritdoc/>
IGuild ICommandContext.Guild => Guild;
/// <inheritdoc/>
IMessageChannel ICommandContext.Channel => Channel;
/// <inheritdoc/>
IUser ICommandContext.User => User;
/// <inheritdoc/>
IUserMessage ICommandContext.Message => Message;
}
}

Loading…
Cancel
Save