* Fix comments to comply with third-person commenting style + Various attributes + Various Command-related objects + Many morepull/988/head
@@ -2,10 +2,17 @@ using System; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> Provides the execution information for a command. </summary> | |||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] | ||||
public class CommandAttribute : Attribute | public class CommandAttribute : Attribute | ||||
{ | { | ||||
/// <summary> | |||||
/// Specifies the text required to be recognized as a command. | |||||
/// </summary> | |||||
public string Text { get; } | public string Text { get; } | ||||
/// <summary> | |||||
/// Specifies the <see cref="RunMode"/> of the command. This affects how the command is executed. | |||||
/// </summary> | |||||
public RunMode RunMode { get; set; } = RunMode.Default; | public RunMode RunMode { get; set; } = RunMode.Default; | ||||
public CommandAttribute() | public CommandAttribute() | ||||
@@ -1,10 +1,10 @@ | |||||
using System; | |||||
using System; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// This attribute requires that the bot has a specified permission in the channel a command is invoked in. | |||||
/// This attribute requires the bot to have a specific permission in the channel a command is invoked in. | |||||
/// </summary> | /// </summary> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
public class RequireBotPermissionAttribute : PreconditionAttribute | public class RequireBotPermissionAttribute : PreconditionAttribute | ||||
@@ -13,7 +13,7 @@ namespace Discord.Commands | |||||
public ChannelPermission? ChannelPermission { get; } | public ChannelPermission? ChannelPermission { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Require that the bot account has a specified GuildPermission | |||||
/// Requires that the bot account to have a specific <see cref="GuildPermission"/>. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks>This precondition will always fail if the command is being invoked in a private channel.</remarks> | /// <remarks>This precondition will always fail if the command is being invoked in a private channel.</remarks> | ||||
/// <param name="permission">The GuildPermission that the bot must have. Multiple permissions can be specified by ORing the permissions together.</param> | /// <param name="permission">The GuildPermission that the bot must have. Multiple permissions can be specified by ORing the permissions together.</param> | ||||
@@ -23,7 +23,7 @@ namespace Discord.Commands | |||||
ChannelPermission = null; | ChannelPermission = null; | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// Require that the bot account has a specified ChannelPermission. | |||||
/// Requires that the bot account to have a specific <see cref="ChannelPermission"/>. | |||||
/// </summary> | /// </summary> | ||||
/// <param name="permission">The ChannelPermission that the bot must have. Multiple permissions can be specified by ORing the permissions together.</param> | /// <param name="permission">The ChannelPermission that the bot must have. Multiple permissions can be specified by ORing the permissions together.</param> | ||||
/// <example> | /// <example> | ||||
@@ -13,7 +13,7 @@ namespace Discord.Commands | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// Require that the command be invoked in a specified context. | |||||
/// This attribute requires that the command be invoked in a specified context. (e.g. in guild, DM) | |||||
/// </summary> | /// </summary> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
public class RequireContextAttribute : PreconditionAttribute | public class RequireContextAttribute : PreconditionAttribute | ||||
@@ -21,7 +21,7 @@ namespace Discord.Commands | |||||
public ContextType Contexts { get; } | public ContextType Contexts { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Require that the command be invoked in a specified context. | |||||
/// Requires that the command be invoked in the specified context. | |||||
/// </summary> | /// </summary> | ||||
/// <param name="contexts">The type of context the command can be invoked in. Multiple contexts can be specified by ORing the contexts together.</param> | /// <param name="contexts">The type of context the command can be invoked in. Multiple contexts can be specified by ORing the contexts together.</param> | ||||
/// <example> | /// <example> | ||||
@@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Require that the command is invoked in a channel marked NSFW | |||||
/// This attribute requires that the command to be invoked in a channel marked NSFW. | |||||
/// </summary> | /// </summary> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
public class RequireNsfwAttribute : PreconditionAttribute | public class RequireNsfwAttribute : PreconditionAttribute | ||||
@@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Require that the command is invoked by the owner of the bot. | |||||
/// This attribute requires that the command to be invoked by the owner of the bot. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks>This precondition will only work if the bot is a bot account.</remarks> | /// <remarks>This precondition will only work if the bot is a bot account.</remarks> | ||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||||
@@ -1,4 +1,4 @@ | |||||
using System; | |||||
using System; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace Discord.Commands | namespace Discord.Commands | ||||
@@ -13,7 +13,7 @@ namespace Discord.Commands | |||||
public ChannelPermission? ChannelPermission { get; } | public ChannelPermission? ChannelPermission { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Require that the user invoking the command has a specified GuildPermission | |||||
/// Requires that the user invoking the command to have a specific <see cref="GuildPermission"/>. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks>This precondition will always fail if the command is being invoked in a private channel.</remarks> | /// <remarks>This precondition will always fail if the command is being invoked in a private channel.</remarks> | ||||
/// <param name="permission">The GuildPermission that the user must have. Multiple permissions can be specified by ORing the permissions together.</param> | /// <param name="permission">The GuildPermission that the user must have. Multiple permissions can be specified by ORing the permissions together.</param> | ||||
@@ -23,7 +23,7 @@ namespace Discord.Commands | |||||
ChannelPermission = null; | ChannelPermission = null; | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// Require that the user invoking the command has a specified ChannelPermission. | |||||
/// Requires that the user invoking the command to have a specific <see cref="ChannelPermission"/>. | |||||
/// </summary> | /// </summary> | ||||
/// <param name="permission">The ChannelPermission that the user must have. Multiple permissions can be specified by ORing the permissions together.</param> | /// <param name="permission">The ChannelPermission that the user must have. Multiple permissions can be specified by ORing the permissions together.</param> | ||||
/// <example> | /// <example> | ||||
@@ -1,13 +1,19 @@ | |||||
namespace Discord.Commands | |||||
namespace Discord.Commands | |||||
{ | { | ||||
public class CommandContext : ICommandContext | public class CommandContext : ICommandContext | ||||
{ | { | ||||
/// <inheritdoc/> | |||||
public IDiscordClient Client { get; } | public IDiscordClient Client { get; } | ||||
/// <inheritdoc/> | |||||
public IGuild Guild { get; } | public IGuild Guild { get; } | ||||
/// <inheritdoc/> | |||||
public IMessageChannel Channel { get; } | public IMessageChannel Channel { get; } | ||||
/// <inheritdoc/> | |||||
public IUser User { get; } | public IUser User { get; } | ||||
/// <inheritdoc/> | |||||
public IUserMessage Message { get; } | public IUserMessage 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 bool IsPrivate => Channel is IPrivateChannel; | ||||
public CommandContext(IDiscordClient client, IUserMessage msg) | public CommandContext(IDiscordClient client, IUserMessage msg) | ||||
@@ -4,7 +4,9 @@ namespace Discord.Commands | |||||
{ | { | ||||
public class CommandException : Exception | public class CommandException : Exception | ||||
{ | { | ||||
/// <summary> The command that caused the exception. </summary> | |||||
public CommandInfo Command { get; } | public CommandInfo Command { get; } | ||||
/// <summary> The command context of the exception. </summary> | |||||
public ICommandContext Context { get; } | public ICommandContext Context { get; } | ||||
public CommandException(CommandInfo command, ICommandContext context, Exception ex) | public CommandException(CommandInfo command, ICommandContext context, Exception ex) | ||||
@@ -1,4 +1,4 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||
@@ -7,7 +7,9 @@ namespace Discord.Commands | |||||
{ | { | ||||
public struct CommandMatch | public struct CommandMatch | ||||
{ | { | ||||
/// <summary> The command that matches the search result. </summary> | |||||
public CommandInfo Command { get; } | public CommandInfo Command { get; } | ||||
/// <summary> The alias of the command. </summary> | |||||
public string Alias { get; } | public string Alias { get; } | ||||
public CommandMatch(CommandInfo command, string alias) | public CommandMatch(CommandInfo command, string alias) | ||||
@@ -12,6 +12,11 @@ using Microsoft.Extensions.DependencyInjection; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
/// <summary> The information of a command. </summary> | |||||
/// <remarks> | |||||
/// This object contains the information of a command. | |||||
/// This can include the module of the command, various descriptions regarding the command, and its <see cref="RunMode"/>. | |||||
/// </remarks> | |||||
[DebuggerDisplay("{Name,nq}")] | [DebuggerDisplay("{Name,nq}")] | ||||
public class CommandInfo | public class CommandInfo | ||||
{ | { | ||||
@@ -21,17 +26,36 @@ namespace Discord.Commands | |||||
private readonly CommandService _commandService; | private readonly CommandService _commandService; | ||||
private readonly Func<ICommandContext, object[], IServiceProvider, CommandInfo, Task> _action; | private readonly Func<ICommandContext, object[], IServiceProvider, CommandInfo, Task> _action; | ||||
/// <summary> The module that the command belongs in. </summary> | |||||
public ModuleInfo Module { get; } | public ModuleInfo Module { get; } | ||||
/// <summary> Name of the command. If none is set, the first alias is used. </summary> | |||||
public string Name { get; } | public string Name { get; } | ||||
/// <summary> Summary of the command. </summary> | |||||
/// <remarks> | |||||
/// This field returns the summary of the command. | |||||
/// Summary and remarks can be useful in help commands and various implementation that fetches details of the command for the user. | |||||
/// </remarks> | |||||
public string Summary { get; } | public string Summary { get; } | ||||
/// <summary> Remarks of the command. </summary> | |||||
/// <remarks> | |||||
/// This field returns the remarks of the command. | |||||
/// Summary and remarks can be useful in help commands and various implementation that fetches details of the command for the user. | |||||
/// </remarks> | |||||
public string Remarks { get; } | public string Remarks { get; } | ||||
/// <summary> The priority of the command. This is used when there are multiple overloads of the command. </summary> | |||||
public int Priority { get; } | public int Priority { get; } | ||||
/// <summary> Indicates whether the command accepts a <see langword="params"/> <see cref="Type"/>[] for its parameter. </summary> | |||||
public bool HasVarArgs { get; } | public bool HasVarArgs { get; } | ||||
/// <summary> Indicates the <see cref="RunMode"/> that is being used for the command. </summary> | |||||
public RunMode RunMode { get; } | public RunMode RunMode { get; } | ||||
/// <summary> List of aliases defined by the <see cref="AliasAttribute"/> of the command. </summary> | |||||
public IReadOnlyList<string> Aliases { get; } | public IReadOnlyList<string> Aliases { get; } | ||||
/// <summary> List of information about the parameters of the command. </summary> | |||||
public IReadOnlyList<ParameterInfo> Parameters { get; } | public IReadOnlyList<ParameterInfo> Parameters { get; } | ||||
/// <summary> List of preconditions defined by the <see cref="PreconditionAttribute"/> of the command. </summary> | |||||
public IReadOnlyList<PreconditionAttribute> Preconditions { get; } | public IReadOnlyList<PreconditionAttribute> Preconditions { get; } | ||||
/// <summary> List of attributes of the command. </summary> | |||||
public IReadOnlyList<Attribute> Attributes { get; } | public IReadOnlyList<Attribute> Attributes { get; } | ||||
internal CommandInfo(CommandBuilder builder, ModuleInfo module, CommandService service) | internal CommandInfo(CommandBuilder builder, ModuleInfo module, CommandService service) | ||||
@@ -122,6 +146,7 @@ namespace Discord.Commands | |||||
return await CommandParser.ParseArgsAsync(this, context, _commandService._ignoreExtraArgs, services, input, 0).ConfigureAwait(false); | return await CommandParser.ParseArgsAsync(this, context, _commandService._ignoreExtraArgs, services, input, 0).ConfigureAwait(false); | ||||
} | } | ||||
/// <summary> Executes the command with the provided context, parsed value, and service provider. </summary> | |||||
public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services) | public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services) | ||||
{ | { | ||||
if (!parseResult.IsSuccess) | if (!parseResult.IsSuccess) | ||||
@@ -145,6 +170,7 @@ namespace Discord.Commands | |||||
return ExecuteAsync(context, argList, paramList, services); | return ExecuteAsync(context, argList, paramList, services); | ||||
} | } | ||||
/// <summary> Executes the command with the provided context, argument and parameter list, and service provider. </summary> | |||||
public async Task<IResult> ExecuteAsync(ICommandContext context, IEnumerable<object> argList, IEnumerable<object> paramList, IServiceProvider services) | public async Task<IResult> ExecuteAsync(ICommandContext context, IEnumerable<object> argList, IEnumerable<object> paramList, IServiceProvider services) | ||||
{ | { | ||||
services = services ?? EmptyServiceProvider.Instance; | services = services ?? EmptyServiceProvider.Instance; | ||||
@@ -1,8 +1,10 @@ | |||||
namespace Discord.Commands | |||||
namespace Discord.Commands | |||||
{ | { | ||||
public enum MultiMatchHandling | public enum MultiMatchHandling | ||||
{ | { | ||||
/// <summary> Indicates that when multiple results are found, an exception should be thrown. </summary> | |||||
Exception, | Exception, | ||||
/// <summary> Indicates that when multiple results are found, the best result should be chosen. </summary> | |||||
Best | Best | ||||
} | } | ||||
} | } |
@@ -1,9 +1,12 @@ | |||||
namespace Discord.Commands | |||||
namespace Discord.Commands | |||||
{ | { | ||||
public interface IResult | public interface IResult | ||||
{ | { | ||||
/// <summary> Describes the error type that may have occurred during the operation. </summary> | |||||
CommandError? Error { get; } | CommandError? Error { get; } | ||||
/// <summary> Describes the reason for the error. </summary> | |||||
string ErrorReason { get; } | string ErrorReason { get; } | ||||
/// <summary> Indicates whether the operation was successful or not. </summary> | |||||
bool IsSuccess { get; } | bool IsSuccess { get; } | ||||
} | } | ||||
} | } |
@@ -1,4 +1,4 @@ | |||||
using System.Collections.Generic; | |||||
using System.Collections.Generic; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord.Commands | namespace Discord.Commands | ||||
@@ -9,9 +9,12 @@ namespace Discord.Commands | |||||
public IReadOnlyList<TypeReaderResult> ArgValues { get; } | public IReadOnlyList<TypeReaderResult> ArgValues { get; } | ||||
public IReadOnlyList<TypeReaderResult> ParamValues { get; } | public IReadOnlyList<TypeReaderResult> ParamValues { get; } | ||||
/// <inheritdoc/> | |||||
public CommandError? Error { get; } | public CommandError? Error { get; } | ||||
/// <inheritdoc/> | |||||
public string ErrorReason { get; } | public string ErrorReason { get; } | ||||
/// <inheritdoc/> | |||||
public bool IsSuccess => !Error.HasValue; | public bool IsSuccess => !Error.HasValue; | ||||
private ParseResult(IReadOnlyList<TypeReaderResult> argValues, IReadOnlyList<TypeReaderResult> paramValues, CommandError? error, string errorReason) | private ParseResult(IReadOnlyList<TypeReaderResult> argValues, IReadOnlyList<TypeReaderResult> paramValues, CommandError? error, string errorReason) | ||||
@@ -1,13 +1,16 @@ | |||||
using System.Diagnostics; | |||||
using System.Diagnostics; | |||||
namespace Discord.Commands | namespace Discord.Commands | ||||
{ | { | ||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class PreconditionResult : IResult | public class PreconditionResult : IResult | ||||
{ | { | ||||
/// <inheritdoc/> | |||||
public CommandError? Error { get; } | public CommandError? Error { get; } | ||||
/// <inheritdoc/> | |||||
public string ErrorReason { get; } | public string ErrorReason { get; } | ||||
/// <inheritdoc/> | |||||
public bool IsSuccess => !Error.HasValue; | public bool IsSuccess => !Error.HasValue; | ||||
protected PreconditionResult(CommandError? error, string errorReason) | protected PreconditionResult(CommandError? error, string errorReason) | ||||
@@ -1,4 +1,4 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
using System.Text; | using System.Text; | ||||
@@ -14,11 +14,15 @@ namespace Discord.Commands | |||||
Reason = reason; | Reason = reason; | ||||
} | } | ||||
/// <inheritdoc/> | |||||
public CommandError? Error { get; } | public CommandError? Error { get; } | ||||
/// <summary> Describes the execution reason or result. </summary> | |||||
public string Reason { get; } | public string Reason { get; } | ||||
/// <inheritdoc/> | |||||
public bool IsSuccess => !Error.HasValue; | public bool IsSuccess => !Error.HasValue; | ||||
/// <inheritdoc/> | |||||
string IResult.ErrorReason => Reason; | string IResult.ErrorReason => Reason; | ||||
public override string ToString() => Reason ?? (IsSuccess ? "Successful" : "Unsuccessful"); | public override string ToString() => Reason ?? (IsSuccess ? "Successful" : "Unsuccessful"); | ||||
@@ -1,4 +1,4 @@ | |||||
using System.Collections.Generic; | |||||
using System.Collections.Generic; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord.Commands | namespace Discord.Commands | ||||
@@ -9,9 +9,12 @@ namespace Discord.Commands | |||||
public string Text { get; } | public string Text { get; } | ||||
public IReadOnlyList<CommandMatch> Commands { get; } | public IReadOnlyList<CommandMatch> Commands { get; } | ||||
/// <inheritdoc/> | |||||
public CommandError? Error { get; } | public CommandError? Error { get; } | ||||
/// <inheritdoc/> | |||||
public string ErrorReason { get; } | public string ErrorReason { get; } | ||||
/// <inheritdoc/> | |||||
public bool IsSuccess => !Error.HasValue; | public bool IsSuccess => !Error.HasValue; | ||||
private SearchResult(string text, IReadOnlyList<CommandMatch> commands, CommandError? error, string errorReason) | private SearchResult(string text, IReadOnlyList<CommandMatch> commands, CommandError? error, string errorReason) | ||||
@@ -1,4 +1,4 @@ | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.Immutable; | using System.Collections.Immutable; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
@@ -26,9 +26,12 @@ namespace Discord.Commands | |||||
{ | { | ||||
public IReadOnlyCollection<TypeReaderValue> Values { get; } | public IReadOnlyCollection<TypeReaderValue> Values { get; } | ||||
/// <inheritdoc/> | |||||
public CommandError? Error { get; } | public CommandError? Error { get; } | ||||
/// <inheritdoc/> | |||||
public string ErrorReason { get; } | public string ErrorReason { get; } | ||||
/// <inheritdoc/> | |||||
public bool IsSuccess => !Error.HasValue; | public bool IsSuccess => !Error.HasValue; | ||||
private TypeReaderResult(IReadOnlyCollection<TypeReaderValue> values, CommandError? error, string errorReason) | private TypeReaderResult(IReadOnlyCollection<TypeReaderValue> values, CommandError? error, string errorReason) | ||||
@@ -3,7 +3,7 @@ namespace Discord.Commands | |||||
public enum RunMode | public enum RunMode | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Default behaviour set in <see cref="CommandServiceConfig"/>. | |||||
/// The default behaviour set in <see cref="CommandServiceConfig"/>. | |||||
/// </summary> | /// </summary> | ||||
Default, | Default, | ||||
/// <summary> | /// <summary> | ||||
@@ -2,6 +2,7 @@ using System; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> Contains the strings related to various Content Delievery Networks (CDNs). </summary> | |||||
public static class CDN | public static class CDN | ||||
{ | { | ||||
/// <summary> Returns the Discord developer application icon. </summary> | /// <summary> Returns the Discord developer application icon. </summary> | ||||
@@ -1,11 +1,16 @@ | |||||
namespace Discord.Commands | |||||
namespace Discord.Commands | |||||
{ | { | ||||
public interface ICommandContext | public interface ICommandContext | ||||
{ | { | ||||
/// <summary> The Discord client of which the command is executed with. </summary> | |||||
IDiscordClient Client { get; } | IDiscordClient Client { get; } | ||||
/// <summary> The guild of which the command is executed in. </summary> | |||||
IGuild Guild { get; } | IGuild Guild { get; } | ||||
/// <summary> The channel of which the command is executed in. </summary> | |||||
IMessageChannel Channel { get; } | IMessageChannel Channel { get; } | ||||
/// <summary> The user who executed the command. </summary> | |||||
IUser User { get; } | IUser User { get; } | ||||
/// <summary> The message of which the command is interpreted from. </summary> | |||||
IUserMessage Message { get; } | IUserMessage Message { get; } | ||||
} | } | ||||
} | } |
@@ -1,7 +1,7 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Modify an IGuildChannel with the specified changes. | |||||
/// Properties that are used to modify an <see cref="IGuildChannel"/> with the specified changes. | |||||
/// </summary> | /// </summary> | ||||
/// <example> | /// <example> | ||||
/// <code language="c#"> | /// <code language="c#"> | ||||
@@ -14,7 +14,7 @@ | |||||
public class GuildChannelProperties | public class GuildChannelProperties | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Set the channel to this name | |||||
/// Sets the channel to this name. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// When modifying an ITextChannel, the Name MUST be alphanumeric with dashes. | /// When modifying an ITextChannel, the Name MUST be alphanumeric with dashes. | ||||
@@ -23,11 +23,11 @@ | |||||
/// <exception cref="Net.HttpException">A BadRequest will be thrown if the name does not match the above RegEx.</exception> | /// <exception cref="Net.HttpException">A BadRequest will be thrown if the name does not match the above RegEx.</exception> | ||||
public Optional<string> Name { get; set; } | public Optional<string> Name { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// Move the channel to the following position. This is 0-based! | |||||
/// Moves the channel to the following position. This is 0-based! | |||||
/// </summary> | /// </summary> | ||||
public Optional<int> Position { get; set; } | public Optional<int> Position { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// Sets the category for this channel | |||||
/// Sets the category for this channel. | |||||
/// </summary> | /// </summary> | ||||
public Optional<ulong?> CategoryId { get; set; } | public Optional<ulong?> CategoryId { get; set; } | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// A unicode emoji | |||||
/// A unicode emoji. | |||||
/// </summary> | /// </summary> | ||||
public class Emoji : IEmote | public class Emoji : IEmote | ||||
{ | { | ||||
@@ -1,19 +1,19 @@ | |||||
using System; | |||||
using System; | |||||
using System.Globalization; | using System.Globalization; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// A custom image-based emote | |||||
/// A custom image-based emote. | |||||
/// </summary> | /// </summary> | ||||
public class Emote : IEmote, ISnowflakeEntity | public class Emote : IEmote, ISnowflakeEntity | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// The display name (tooltip) of this emote | |||||
/// The display name (tooltip) of this emote. | |||||
/// </summary> | /// </summary> | ||||
public string Name { get; } | public string Name { get; } | ||||
/// <summary> | /// <summary> | ||||
/// The ID of this emote | |||||
/// The ID of this emote. | |||||
/// </summary> | /// </summary> | ||||
public ulong Id { get; } | public ulong Id { get; } | ||||
/// <summary> | /// <summary> | ||||
@@ -50,7 +50,7 @@ namespace Discord | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// Parse an Emote from its raw format | |||||
/// Parses an Emote from its raw format. | |||||
/// </summary> | /// </summary> | ||||
/// <param name="text">The raw encoding of an emote; for example, <:dab:277855270321782784></param> | /// <param name="text">The raw encoding of an emote; for example, <:dab:277855270321782784></param> | ||||
/// <returns>An emote</returns> | /// <returns>An emote</returns> | ||||
@@ -1,10 +1,10 @@ | |||||
using System.Collections.Generic; | |||||
using System.Collections.Generic; | |||||
using System.Diagnostics; | using System.Diagnostics; | ||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// An image-based emote that is attached to a guild | |||||
/// An image-based emote that is attached to a guild. | |||||
/// </summary> | /// </summary> | ||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class GuildEmote : Emote | public class GuildEmote : Emote | ||||
@@ -1,7 +1,7 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Modify the widget of an IGuild with the specified parameters | |||||
/// Properties that are used to modify the widget of an <see cref="IGuild"/> with the specified parameters. | |||||
/// </summary> | /// </summary> | ||||
public class GuildEmbedProperties | public class GuildEmbedProperties | ||||
{ | { | ||||
@@ -1,7 +1,7 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Modify an IGuild with the specified changes | |||||
/// Properties that are used to modify an <see cref="IGuild"/> with the specified changes. | |||||
/// </summary> | /// </summary> | ||||
/// <example> | /// <example> | ||||
/// <code language="c#"> | /// <code language="c#"> | ||||
@@ -17,23 +17,23 @@ | |||||
{ | { | ||||
public Optional<string> Username { get; set; } | public Optional<string> Username { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The name of the Guild | |||||
/// The name of the Guild. | |||||
/// </summary> | /// </summary> | ||||
public Optional<string> Name { get; set; } | public Optional<string> Name { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The region for the Guild's voice connections | |||||
/// The region for the Guild's voice connections. | |||||
/// </summary> | /// </summary> | ||||
public Optional<IVoiceRegion> Region { get; set; } | public Optional<IVoiceRegion> Region { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The ID of the region for the Guild's voice connections | |||||
/// The ID of the region for the Guild's voice connections. | |||||
/// </summary> | /// </summary> | ||||
public Optional<string> RegionId { get; set; } | public Optional<string> RegionId { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// What verification level new users need to achieve before speaking | |||||
/// What verification level new users need to achieve before speaking. | |||||
/// </summary> | /// </summary> | ||||
public Optional<VerificationLevel> VerificationLevel { get; set; } | public Optional<VerificationLevel> VerificationLevel { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The default message notification state for the guild | |||||
/// The default message notification state for the guild. | |||||
/// </summary> | /// </summary> | ||||
public Optional<DefaultMessageNotifications> DefaultMessageNotifications { get; set; } | public Optional<DefaultMessageNotifications> DefaultMessageNotifications { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -41,11 +41,11 @@ | |||||
/// </summary> | /// </summary> | ||||
public Optional<int> AfkTimeout { get; set; } | public Optional<int> AfkTimeout { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The icon of the guild | |||||
/// The icon of the guild. | |||||
/// </summary> | /// </summary> | ||||
public Optional<Image?> Icon { get; set; } | public Optional<Image?> Icon { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The guild's splash image | |||||
/// The guild's splash image. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// The guild must be partnered for this value to have any effect. | /// The guild must be partnered for this value to have any effect. | ||||
@@ -1,5 +1,6 @@ | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> The interface that defines an attachment object. </summary> | |||||
public interface IAttachment | public interface IAttachment | ||||
{ | { | ||||
/// <summary> The snowflake ID of the attachment. </summary> | /// <summary> The snowflake ID of the attachment. </summary> | ||||
@@ -1,7 +1,7 @@ | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Modify a message with the specified parameters. | |||||
/// Properties that are used to modify a message with the specified parameters. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// The content of a message can be cleared with String.Empty; if and only if an Embed is present. | /// The content of a message can be cleared with String.Empty; if and only if an Embed is present. | ||||
@@ -23,14 +23,14 @@ | |||||
public class MessageProperties | public class MessageProperties | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// The content of the message | |||||
/// The content of the message. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// This must be less than 2000 characters. | /// This must be less than 2000 characters. | ||||
/// </remarks> | /// </remarks> | ||||
public Optional<string> Content { get; set; } | public Optional<string> Content { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// The embed the message should display | |||||
/// The embed the message should display. | |||||
/// </summary> | /// </summary> | ||||
public Optional<Embed> Embed { get; set; } | public Optional<Embed> Embed { get; set; } | ||||
} | } | ||||
@@ -1,9 +1,9 @@ | |||||
using System.Collections.Generic; | |||||
using System.Collections.Generic; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Modify an IGuildUser with the following parameters. | |||||
/// Properties that are used to modify an <see cref="IGuildUser"/> with the following parameters. | |||||
/// </summary> | /// </summary> | ||||
/// <example> | /// <example> | ||||
/// <code language="c#"> | /// <code language="c#"> | ||||
@@ -54,14 +54,14 @@ namespace Discord | |||||
/// </remarks> | /// </remarks> | ||||
public Optional<IEnumerable<ulong>> RoleIds { get; set; } | public Optional<IEnumerable<ulong>> RoleIds { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// Move a user to a voice channel. | |||||
/// Moves a user to a voice channel. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// This user MUST already be in a Voice Channel for this to work. | /// This user MUST already be in a Voice Channel for this to work. | ||||
/// </remarks> | /// </remarks> | ||||
public Optional<IVoiceChannel> Channel { get; set; } | public Optional<IVoiceChannel> Channel { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// Move a user to a voice channel. | |||||
/// Moves a user to a voice channel. | |||||
/// </summary> | /// </summary> | ||||
/// <remarks> | /// <remarks> | ||||
/// This user MUST already be in a Voice Channel for this to work. | /// This user MUST already be in a Voice Channel for this to work. | ||||
@@ -4,6 +4,7 @@ using System.Text; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A helper class for mention-related parsing. </summary> | |||||
public static class MentionUtils | public static class MentionUtils | ||||
{ | { | ||||
private const char SanitizeChar = '\x200b'; | private const char SanitizeChar = '\x200b'; | ||||
@@ -3,6 +3,7 @@ using Model = Discord.API.Attachment; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
/// <summary> A Discord attachment. </summary> | |||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")] | [DebuggerDisplay(@"{DebuggerDisplay,nq}")] | ||||
public class Attachment : IAttachment | public class Attachment : IAttachment | ||||
{ | { | ||||
@@ -38,6 +39,7 @@ namespace Discord | |||||
model.Width.IsSpecified ? model.Width.Value : (int?)null); | model.Width.IsSpecified ? model.Width.Value : (int?)null); | ||||
} | } | ||||
/// <summary> Returns the filename of the attachment. </summary> | |||||
public override string ToString() => Filename; | public override string ToString() => Filename; | ||||
private string DebuggerDisplay => $"{Filename} ({Size} bytes)"; | private string DebuggerDisplay => $"{Filename} ({Size} bytes)"; | ||||
} | } | ||||