Browse Source

Add XML docs

pull/1161/head
Still Hsu 7 years ago
parent
commit
90fdd54926
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
8 changed files with 131 additions and 6 deletions
  1. +36
    -3
      src/Discord.Net.Commands/CommandService.cs
  2. +7
    -1
      src/Discord.Net.Commands/Extensions/MessageExtensions.cs
  3. +36
    -0
      src/Discord.Net.Commands/Info/ModuleInfo.cs
  4. +27
    -0
      src/Discord.Net.Commands/Info/ParameterInfo.cs
  5. +3
    -0
      src/Discord.Net.Commands/Results/ExecuteResult.cs
  6. +1
    -1
      src/Discord.Net.Core/Extensions/MessageExtensions.cs
  7. +20
    -0
      src/Discord.Net.WebSocket/DiscordSocketClient.cs
  8. +1
    -1
      src/Discord.Net.WebSocket/Entities/Users/SocketSelfUser.cs

+ 36
- 3
src/Discord.Net.Commands/CommandService.cs View File

@@ -11,6 +11,22 @@ using Discord.Logging;

namespace Discord.Commands
{
/// <summary>
/// Provides a framework for building Discord commands.
/// </summary>
/// <remarks>
/// <para>
/// The service provides a framework for building Discord commands both dynamically via runtime builders or
/// statically via compile-time modules. To create a command module at compile-time, see
/// <see cref="ModuleBase" /> (most common); otherwise, see <see cref="ModuleBuilder" />.
/// </para>
/// <para>
/// This service also provides several events for monitoring command usages; such as
/// <see cref="Discord.Commands.CommandService.Log" /> for any command-related log events, and
/// <see cref="Discord.Commands.CommandService.CommandExecuted" /> for information about commands that have
/// been successfully executed.
/// </para>
/// </remarks>
public class CommandService
{
/// <summary>
@@ -20,8 +36,19 @@ namespace Discord.Commands
internal readonly AsyncEvent<Func<LogMessage, Task>> _logEvent = new AsyncEvent<Func<LogMessage, Task>>();

/// <summary>
/// Occurs when a command is successfully executed without any runtime error.
/// Occurs when a command is successfully executed without any error.
/// </summary>
/// <remarks>
/// <para>
/// This event is fired when a command has been successfully executed without any of the following errors:
/// </para>
/// <para>* Parsing error</para>
/// <para>* Precondition error</para>
/// <para>* Runtime exception</para>
/// <para>
/// Should the command encounter any of the aforementioned error, this event will not be raised.
/// </para>
/// </remarks>
public event Func<CommandInfo, ICommandContext, IResult, Task> CommandExecuted { add { _commandExecutedEvent.Add(value); } remove { _commandExecutedEvent.Remove(value); } }
internal readonly AsyncEvent<Func<CommandInfo, ICommandContext, IResult, Task>> _commandExecutedEvent = new AsyncEvent<Func<CommandInfo, ICommandContext, IResult, Task>>();

@@ -132,8 +159,14 @@ namespace Discord.Commands
/// <summary>
/// Add a command module from a <see cref="Type" /> .
/// </summary>
/// <example>
/// <para>The following example registers the module <c>MyModule</c> to <c>commandService</c>.</para>
/// <code language="cs">
/// await commandService.AddModuleAsync&lt;MyModule&gt;(serviceProvider);
/// </code>
/// </example>
/// <typeparam name="T">The type of module.</typeparam>
/// <param name="services">The <see cref="IServiceProvider" /> for your dependency injection solution if using one; otherwise, pass <c>null</c> .</param>
/// <param name="services">The <see cref="IServiceProvider"/> for your dependency injection solution if using one; otherwise, pass <c>null</c>.</param>
/// <exception cref="ArgumentException">This module has already been added.</exception>
/// <exception cref="InvalidOperationException">
/// The <see cref="ModuleInfo"/> fails to be built; an invalid type may have been provided.
@@ -145,7 +178,7 @@ namespace Discord.Commands
public Task<ModuleInfo> AddModuleAsync<T>(IServiceProvider services) => AddModuleAsync(typeof(T), services);

/// <summary>
/// Adds a command module from a <see cref="Type" /> .
/// Adds a command module from a <see cref="Type" />.
/// </summary>
/// <param name="type">The type of module.</param>
/// <param name="services">The <see cref="IServiceProvider" /> for your dependency injection solution if using one; otherwise, pass <c>null</c> .</param>


+ 7
- 1
src/Discord.Net.Commands/Extensions/MessageExtensions.cs View File

@@ -3,13 +3,19 @@ using System;
namespace Discord.Commands
{
/// <summary>
/// Extension methods for <see cref="IUserMessage"/> that related to commands.
/// Provides extension methods for <see cref="IUserMessage" /> that relates to commands.
/// </summary>
public static class MessageExtensions
{
/// <summary>
/// Gets whether the message starts with the provided character.
/// </summary>
/// <param name="msg">The message to check against.</param>
/// <param name="c">The char prefix.</param>
/// <param name="argPos">References where the command starts.</param>
/// <returns>
/// <c>true</c> if the message begins with the char <paramref name="c"/>; otherwise <c>false</c>.
/// </returns>
public static bool HasCharPrefix(this IUserMessage msg, char c, ref int argPos)
{
var text = msg.Content;


+ 36
- 0
src/Discord.Net.Commands/Info/ModuleInfo.cs View File

@@ -11,18 +11,54 @@ namespace Discord.Commands
/// </summary>
public class ModuleInfo
{
/// <summary>
/// Gets the command service associated with this module.
/// </summary>
public CommandService Service { get; }
/// <summary>
/// Gets the name of this module.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets the summary of this module.
/// </summary>
public string Summary { get; }
/// <summary>
/// Gets the remarks of this module.
/// </summary>
public string Remarks { get; }
/// <summary>
/// Gets the group name (main prefix) of this module.
/// </summary>
public string Group { get; }

/// <summary>
/// Gets a read-only list of aliases associated with this module.
/// </summary>
public IReadOnlyList<string> Aliases { get; }
/// <summary>
/// Gets a read-only list of commands associated with this module.
/// </summary>
public IReadOnlyList<CommandInfo> Commands { get; }
/// <summary>
/// Gets a read-only list of preconditions that apply to this module.
/// </summary>
public IReadOnlyList<PreconditionAttribute> Preconditions { get; }
/// <summary>
/// Gets a read-only list of attributes that apply to this module.
/// </summary>
public IReadOnlyList<Attribute> Attributes { get; }
/// <summary>
/// Gets a read-only list of submodules associated with tihs module.
/// </summary>
public IReadOnlyList<ModuleInfo> Submodules { get; }
/// <summary>
/// Gets the parent module of this submodule if applicable.
/// </summary>
public ModuleInfo Parent { get; }
/// <summary>
/// Gets a value that indicates whether this module is a submodule or not.
/// </summary>
public bool IsSubmodule => Parent != null;

internal ModuleInfo(ModuleBuilder builder, CommandService service, IServiceProvider services, ModuleInfo parent = null)


+ 27
- 0
src/Discord.Net.Commands/Info/ParameterInfo.cs View File

@@ -15,16 +15,43 @@ namespace Discord.Commands
{
private readonly TypeReader _reader;

/// <summary>
/// Gets the command that associates with this parameter.
/// </summary>
public CommandInfo Command { get; }
/// <summary>
/// Gets the name of this parameter.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets the summary of this parameter.
/// </summary>
public string Summary { get; }
/// <summary>
/// Gets a value that indicates whether this parameter is optional or not.
/// </summary>
public bool IsOptional { get; }
/// <summary>
/// Gets a value that indicates whether this parameter is a remainder parameter or not.
/// </summary>
public bool IsRemainder { get; }
public bool IsMultiple { get; }
/// <summary>
/// Gets the type of the parameter.
/// </summary>
public Type Type { get; }
/// <summary>
/// Gets the default value for this optional parameter if applicable.
/// </summary>
public object DefaultValue { get; }

/// <summary>
/// Gets a read-only list of precondition that apply to this parameter.
/// </summary>
public IReadOnlyList<ParameterPreconditionAttribute> Preconditions { get; }
/// <summary>
/// Gets a read-only list of attributes that apply to this parameter.
/// </summary>
public IReadOnlyList<Attribute> Attributes { get; }

internal ParameterInfo(ParameterBuilder builder, CommandInfo command, CommandService service)


+ 3
- 0
src/Discord.Net.Commands/Results/ExecuteResult.cs View File

@@ -6,6 +6,9 @@ namespace Discord.Commands
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct ExecuteResult : IResult
{
/// <summary>
/// Gets the exception that may have occurred during the command execution.
/// </summary>
public Exception Exception { get; }

/// <inheritdoc />


+ 1
- 1
src/Discord.Net.Core/Extensions/MessageExtensions.cs View File

@@ -1,7 +1,7 @@
namespace Discord
{
/// <summary>
/// Provides extension methods for <see cref="IMessage"/>.
/// Provides extension methods for <see cref="IMessage" />.
/// </summary>
public static class MessageExtensions
{


+ 20
- 0
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -361,6 +361,12 @@ namespace Discord.WebSocket
}

/// <inheritdoc />
/// <example>
/// The following example sets the status of the current user to Do Not Disturb.
/// <code language="cs">
/// await client.SetStatusAsync(UserStatus.DoNotDisturb);
/// </code>
/// </example>
public override async Task SetStatusAsync(UserStatus status)
{
Status = status;
@@ -371,6 +377,20 @@ namespace Discord.WebSocket
await SendStatusAsync().ConfigureAwait(false);
}
/// <inheritdoc />
/// <example>
/// <para>
/// The following example sets the activity of the current user to the specified game name.
/// <code language="cs">
/// await client.SetGameAsync("A Strange Game");
/// </code>
/// </para>
/// <para>
/// The following example sets the activity of the current user to a streaming status.
/// <code language="cs">
/// await client.SetGameAsync("Great Stream 10/10", "https://twitch.tv/MyAmazingStream1337", ActivityType.Streaming);
/// </code>
/// </para>
/// </example>
public override async Task SetGameAsync(string name, string streamUrl = null, ActivityType type = ActivityType.Playing)
{
if (!string.IsNullOrEmpty(streamUrl))


+ 1
- 1
src/Discord.Net.WebSocket/Entities/Users/SocketSelfUser.cs View File

@@ -7,7 +7,7 @@ using Model = Discord.API.User;
namespace Discord.WebSocket
{
/// <summary>
/// Represents the logged-in WebSocker-based user.
/// Represents the logged-in WebSocket-based user.
/// </summary>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class SocketSelfUser : SocketUser, ISelfUser


Loading…
Cancel
Save