Documentation Overhaul (#1161)
* Add XML docs
* Clean up style switcher
* Squash commits on branch docs/faq-n-patches
* Fix broken theme selector
* Add local image embed instruction
* Add a bunch of XML docs
* Add a bunch of XML docs
* Fix broken search
+ DocFX by default ships with an older version of jQuery, switching to a newer version confuses parts of the DocFX Javascript.
* Minor fixes for CONTRIBUTING.md and README.md
* Clean up filterConfig.yml
+ New config exposes Discord.Net namespace since it has several common public exceptions that may be helpful to users
* Add XML docs
* Read token from Environment Variable instead of hardcode
* Add XMLDocs
* Compress some assets & add OAuth2 URL generator
* Fix sample link & add missing pictures
* Add tag examples
* Fix embed docs consistency
* Add details regarding userbot support
* Add XML Docs
* Add XML Docs
* Add XML Docs
* Minor fixes in documentations
+ Fix unescaped '<'
+ Fix typo
* Fix seealso for preconditions and add missing descriptions
* Add missing exceptions
* Document exposed TypeReaders
* Fix letter-casing for files
* Add 'last modified' plugin
Source: https://github.com/Still34/DocFx.Plugin.LastModified
Licensed under MIT License
* XML Docs
* Fix minor consistencies & redundant impl
* Add properties examples to overwrite
* Fix missing Username prop
* Add warning for bulk-delete endpoint
* Replace note block
* Add BaseSocketClient docs
* Add XML docs
* Replace langword null to code block null instead
- Because DocFX sucks at rendering langword
* Replace all langword placements with code block
* Add more IGuild docs
* Add details to SpotifyGame
* Initial proofread of the articles
* Add explanation for RunMode
* Add event docs
- MessageReceived
- ChannelUpdated/Destroyed/Created
* Fix light theme link color
* Fix xml docs error
* Add partial documentation for audit log impl
* Add documentation for some REST-based objects
* Add partial documentation for audit log objects
* Add more XML comments to quotation mark alias map stuff, including an example
* Add reference to CommandServiceConfig from the util docs'
* Add explanation that if " is removed then it wont work
* Fix missing service provider in example
* Add documentation for new INestedChannel
* Add documentation
* Add documentation for new API version & few events
* Revise guide paragraphs/samples
+ Fix various formatting.
+ Provide a more detailed walkthrough for dependency injection.
+ Add C# note at intro.
* Fix typos & formatting
* Improve group module example
* Small amount to see if I'm doing it right
* Remove/cleanup redundant variables
* Fix EnterTypingState impl for doc inheritance
* Fix Test to resolve changes made in 15b58e
* Improve precondition documentation
+ Add precondition usage sample
+ Add precondition group usage sample
+ Move precondition samples to its own sample folder
* Move samples to individual folders
* Clarify token source
* Cleanup styling of README.md for docs
* Replace InvalidPathChars for NS1.3
* InvalidPathChars does not exist in NS1.3; replaced with GetInvalidPathChars instead.
* Add a missing change for 2c7cc738
* Update LastModified to v1.1.0 & add license
* Rewrite installation page for Core 2.1
* Fix anchor link
* Bump post-processor to v1.1.1
* Add fixes to partial file & add license
* Moved theme-switcher code to scripts partial file
+ Add author's MIT license to featherlight javascript
* Remove unused bootstrap plugin
* Bump LastModified plugin
* Changed the path from 'lastmodified' to 'last-modified' for consistency
* Cleanup README & Contribution guide
* Changes to last pr
* Fix GetCategoryAsync docs
* Proofread and cleanup articles
* Change passive voice in "Get Started" to active
* Fix improper preposition in Commands Introduction page
* Fix minor grammar mistakes in "Your First Bot" (future tense -> present tense/subjunctive mood -> indicative mood/proper noun casing/incorrect noun/add missing article)
* Fix minor grammar mistakes in "Installation" (missing article)
* no hablo ingles
* Try try try again
* I'm sure you're having as much fun as I am
* Cleanup TOC & fix titles
* Improve styling
+ Change title font to Noto Sans
+ Add materialized design for commit message box
* Add DescriptionGenerator plugin
* Add nightly section for clarification
* Fix typos in Nightlies & Post-execution
* Bump DescriptionGenerator to v1.1.0
+ This build adds the functionality of generating managed references' summary into the description tag.
* Initial emoji article draft
* Add 'additional information' section for emoji article
* Add cosmetic changes to the master css
* Alter info box color
+ Add transition to article content
* Add clarification in the emoji article
* Emphasize that normal emoji string will not translate to its Unicode representation.
* Clean up or add some of the samples featured in the article.
+ Add emoji/emote declaration section for clarification.
+ Add WebSocket emote sample.
- Remove inconsistent styling ('wacky memes' proves to be too out of place).
* Improve readability for nightlies article
* Move 'Bundled Preconditions' section
* Bump LastModified to fix UTC DateTime parsing
* Add langwordMapping.yml
* Add XML docs
* Add VSC workspace rule
* The root workspace limits the ruler to 120 characters for member documentations and excludes folders such as 'samples' and 'docs'.
* The docs workspace limits the ruler to 70 characters for standard conceptual article to comply with documentation's CONTRIBUTING.md rule, and excludes temprorary folders created by DocFX.
* Update CONTRIBUTING.md
* Add documentation style rule
* Fix styling of several member documentation
* Fix ' />' caused by Agent Smith oddities
* Fix styling to be more specific about the mention of IDs
* Fix exception summary to comply with official Microsoft Docs style
* References
https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception?view=netframework-4.7.2
https://docs.microsoft.com/en-us/dotnet/api/system.platformnotsupportedexception?view=netframework-4.7.2
https://docs.microsoft.com/en-us/dotnet/api/system.badimageformatexception?view=netframework-4.7.2
* Add XML documentations
* Shift color return docs
* Fix minor docs
* Added documentation for SocketDMChannel, SocketGuildChannel, and SocketTextChannel
* Add XML docs
* Corrections to SocketGuildChannel
* Corrections to SocketTextChannel
* Corrections to SocketDMChannel
* Swapped out 'id' for 'snowflake identifier
* Swapped out 'id' for 'snowflake identifier'
* SocketDMChannel amendments
* SocketGuildChannel amendments
* SocketTextChannel amendments
* Add XML docs & patch return types
+ Starting from this commit, all return types for tasks will use style similar to most documentations featured on docs.microsoft.com
References:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.dbcontext.-ctor?view=efcore-2.1
https://docs.microsoft.com/en-us/dotnet/api/system.io.filestream.readasync?view=netcore-2.1
https://docs.microsoft.com/en-us/dotnet/api/system.io.textwriter.writelineasync?view=netcore-2.1#System_IO_TextWriter_WriteLineAsync_System_Char___
And many more other asynchronous method documentations featured in the latest BCL.
* Added documentation for many audit log data types, fixed vowel indefinite articles
* Change audit log data types to start with 'Contains' (verb) instead of an article
* Fix some documentation issues and document some more audit log data types
* Fix English posession
* Add XML doc
* Documented two more types
* Documented RoleCreateAuditLogData
* Document remaining audit log data types
* Added RestDMChannel documentation
* Added RestGuildChannel documentation
* Added RestTextChannel documentation
* Added RestVoiceChannel documentation
* Added RestUser documentation
* Added RestRole documentation
* Added RestMessage documentation
* Slightly better wording
* Contains -> Contains a piece of (describe article)
* [EN] Present perf. -> past perf.
* Add XML docs
* Fix arrow alignment
* Clarify supported nullable type
* Fixed a typo in ISnowflakeEntity
* Added RestUser Documentation
* Added RestInvite documentation
* Add XML docs & minor optimizations
* Minor optimization for doc rendering
* Rollback font optimization changes
* Amendments to RestUser
* Added SocketDMChannel documentation
* Added RestDMChannel documentation
* Added RestGuild documentation
* Adjustment to SocketDMChannel
* Added minimal descriptions from the API documentation for Integration types
* Added obsolete mention to the ReadMessages flag.
* Added remarks about 2FA requirement for guild permissions
* Added xmldoc for GuildPermission methods
* Added xml doc for ToAllowList and ToDenyList
* Added specification of how the bits of the color raw value are packed
* Added discord API documentation to IConnection interface
* I can spell :^)
* Fix whitespace in ChannelPermission
* fix spacing of values in guildpermission
* Made changes to get field descriptions from feedback, added returns tag to IConnection
* Added property get standard for IntegrationAccount
* Added property get pattern to xml docs and identical returns tag.
* Change all color class references to struct
...because it isn't a class.
* Add XML docs
* Rewrote the returns tags in IGuildIntegration, removed the ones I was unsure about.
* Rewrote the rest of the returns tags
* Amendments
* Cleanup doc for c1d78189
* Added types to <returns> tags where missing
* Added second sample for adding reactions
* Added some class summaries
* Missed a period
* Amendments
* restored the removed line break
* Removed unnecessary see tag
* Use consistent quotation marks around subscribers, the name for these users are dependant on the source of where they are integrated from (youtube or twitch), so we should not use a name that is specific to one platform
* Add <remarks> tag to the IGuildIntegration xmldocs
* Fix grammar issue
* Update DescriptionGenerator
* Cleanup of https://github.com/Still34/Discord.Net/pull/8
* Cleanup previous PR
* Fix for misleading behaviour in the emoji guide
+ Original lines stated that sending a emoji wrapped in colon will not be parsed, but that was incorrect; replaced with reactions instead of sending messages as the example
* Add strings for dictionary in DotSettings
* Add XML docs
* Fix lots of typos in comments
+ Geez, I didn't know there were so many.
* Add XML docs & rewrite GetMessagesAsync docs
This commit rewrites the remarks section of GetMessagesAsync, as well as adding examples to several methods.
* Update 'Your First Bot'
+ This commit reflects the new changes made to the Discord Application Developer Portal after its major update
* Initial optimization for DocFX render & add missing files
* Add examples in message methods
* Cleanup https://github.com/RogueException/Discord.Net/pull/1128
* Fix first bot note
* Cleanup FAQ structure
* Add XML docs
* Update docfx plugins
* Fix navbar collapsing issue
* Fix broken xref
* Cleanup FAQ section
+ Add introductory paragraphs to each FAQ section.
+ Add 'missing dependency' entry to commands FAQ.
* Split commands FAQ to 'General' and 'DI' sections.
* Cleanup https://github.com/RogueException/Discord.Net/pull/1139
* Fix missing namespace
* Add missing highlighting css for the light theme
* Add additional clarification for installing packages
* Add indentation to example for clarity
* Cleanup several articles to be more human-friendly and easier to read
* Remove RPC-related notes
* Cleanup slow-mode-related documentation strings
* Add an additional note about cross-guild emote usage
* Add CreateTextChannel sample
* Add XMLDocs
This commit is contained in:
@@ -11,11 +11,44 @@ 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>
|
||||
/// Occurs when a command-related information is received.
|
||||
/// </summary>
|
||||
public event Func<LogMessage, Task> Log { add { _logEvent.Add(value); } remove { _logEvent.Remove(value); } }
|
||||
internal readonly AsyncEvent<Func<LogMessage, Task>> _logEvent = new AsyncEvent<Func<LogMessage, Task>>();
|
||||
|
||||
/// <summary>
|
||||
/// 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>>();
|
||||
|
||||
@@ -34,11 +67,33 @@ namespace Discord.Commands
|
||||
internal readonly LogManager _logManager;
|
||||
internal readonly IReadOnlyDictionary<char, char> _quotationMarkAliasMap;
|
||||
|
||||
/// <summary>
|
||||
/// Represents all modules loaded within <see cref="CommandService"/>.
|
||||
/// </summary>
|
||||
public IEnumerable<ModuleInfo> Modules => _moduleDefs.Select(x => x);
|
||||
|
||||
/// <summary>
|
||||
/// Represents all commands loaded within <see cref="CommandService"/>.
|
||||
/// </summary>
|
||||
public IEnumerable<CommandInfo> Commands => _moduleDefs.SelectMany(x => x.Commands);
|
||||
|
||||
/// <summary>
|
||||
/// Represents all <see cref="TypeReader" /> loaded within <see cref="CommandService"/>.
|
||||
/// </summary>
|
||||
public ILookup<Type, TypeReader> TypeReaders => _typeReaders.SelectMany(x => x.Value.Select(y => new { y.Key, y.Value })).ToLookup(x => x.Key, x => x.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="CommandService"/> class.
|
||||
/// </summary>
|
||||
public CommandService() : this(new CommandServiceConfig()) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="CommandService"/> class with the provided configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">The configuration class.</param>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// The <see cref="RunMode"/> cannot be set to <see cref="RunMode.Default"/>.
|
||||
/// </exception>
|
||||
public CommandService(CommandServiceConfig config)
|
||||
{
|
||||
_caseSensitive = config.CaseSensitiveCommands;
|
||||
@@ -102,12 +157,39 @@ namespace Discord.Commands
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a command module from a type
|
||||
/// Add a command module from a <see cref="Type" />.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of module</typeparam>
|
||||
/// <param name="services">An IServiceProvider for your dependency injection solution, if using one - otherwise, pass null</param>
|
||||
/// <returns>A built module</returns>
|
||||
/// <example>
|
||||
/// <para>The following example registers the module <c>MyModule</c> to <c>commandService</c>.</para>
|
||||
/// <code language="cs">
|
||||
/// await commandService.AddModuleAsync<MyModule>(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>
|
||||
/// <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.
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous operation for adding the module. The task result contains the
|
||||
/// built module.
|
||||
/// </returns>
|
||||
public Task<ModuleInfo> AddModuleAsync<T>(IServiceProvider services) => AddModuleAsync(typeof(T), services);
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// <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.
|
||||
/// </exception>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous operation for adding the module. The task result contains the
|
||||
/// built module.
|
||||
/// </returns>
|
||||
public async Task<ModuleInfo> AddModuleAsync(Type type, IServiceProvider services)
|
||||
{
|
||||
services = services ?? EmptyServiceProvider.Instance;
|
||||
@@ -135,11 +217,14 @@ namespace Discord.Commands
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Add command modules from an assembly
|
||||
/// Add command modules from an <see cref="Assembly"/>.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The assembly containing command modules</param>
|
||||
/// <param name="services">An IServiceProvider for your dependency injection solution, if using one - otherwise, pass null</param>
|
||||
/// <returns>A collection of built modules</returns>
|
||||
/// <param name="assembly">The <see cref="Assembly"/> containing command modules.</param>
|
||||
/// <param name="services">The <see cref="IServiceProvider"/> for your dependency injection solution if using one; otherwise, pass <c>null</c>.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous operation for adding the command modules. The task result
|
||||
/// contains an enumerable collection of modules added.
|
||||
/// </returns>
|
||||
public async Task<IEnumerable<ModuleInfo>> AddModulesAsync(Assembly assembly, IServiceProvider services)
|
||||
{
|
||||
services = services ?? EmptyServiceProvider.Instance;
|
||||
@@ -175,7 +260,14 @@ namespace Discord.Commands
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the command module.
|
||||
/// </summary>
|
||||
/// <param name="module">The <see cref="ModuleInfo" /> to be removed from the service.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous removal operation. The task result contains a value that
|
||||
/// indicates whether the <paramref name="module"/> is successfully removed.
|
||||
/// </returns>
|
||||
public async Task<bool> RemoveModuleAsync(ModuleInfo module)
|
||||
{
|
||||
await _moduleLock.WaitAsync().ConfigureAwait(false);
|
||||
@@ -188,7 +280,23 @@ namespace Discord.Commands
|
||||
_moduleLock.Release();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes the command module.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The <see cref="Type"/> of the module.</typeparam>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous removal operation. The task result contains a value that
|
||||
/// indicates whether the module is successfully removed.
|
||||
/// </returns>
|
||||
public Task<bool> RemoveModuleAsync<T>() => RemoveModuleAsync(typeof(T));
|
||||
/// <summary>
|
||||
/// Removes the command module.
|
||||
/// </summary>
|
||||
/// <param name="type">The <see cref="Type"/> of the module.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous removal operation. The task result contains a value that
|
||||
/// indicates whether the module is successfully removed.
|
||||
/// </returns>
|
||||
public async Task<bool> RemoveModuleAsync(Type type)
|
||||
{
|
||||
await _moduleLock.WaitAsync().ConfigureAwait(false);
|
||||
@@ -222,21 +330,27 @@ namespace Discord.Commands
|
||||
|
||||
//Type Readers
|
||||
/// <summary>
|
||||
/// Adds a custom <see cref="TypeReader"/> to this <see cref="CommandService"/> for the supplied object type.
|
||||
/// If <typeparamref name="T"/> is a <see cref="ValueType"/>, a <see cref="NullableTypeReader{T}"/> will also be added.
|
||||
/// If a default <see cref="TypeReader"/> exists for <typeparamref name="T"/>, a warning will be logged and the default <see cref="TypeReader"/> will be replaced.
|
||||
/// Adds a custom <see cref="TypeReader" /> to this <see cref="CommandService" /> for the supplied object
|
||||
/// type.
|
||||
/// If <typeparamref name="T" /> is a <see cref="ValueType" />, a nullable <see cref="TypeReader" /> will
|
||||
/// also be added.
|
||||
/// If a default <see cref="TypeReader" /> exists for <typeparamref name="T" />, a warning will be logged
|
||||
/// and the default <see cref="TypeReader" /> will be replaced.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The object type to be read by the <see cref="TypeReader"/>.</typeparam>
|
||||
/// <param name="reader">An instance of the <see cref="TypeReader"/> to be added.</param>
|
||||
/// <param name="reader">An instance of the <see cref="TypeReader" /> to be added.</param>
|
||||
public void AddTypeReader<T>(TypeReader reader)
|
||||
=> AddTypeReader(typeof(T), reader);
|
||||
/// <summary>
|
||||
/// Adds a custom <see cref="TypeReader"/> to this <see cref="CommandService"/> for the supplied object type.
|
||||
/// If <paramref name="type"/> is a <see cref="ValueType"/>, a <see cref="NullableTypeReader{T}"/> for the value type will also be added.
|
||||
/// If a default <see cref="TypeReader"/> exists for <paramref name="type"/>, a warning will be logged and the default <see cref="TypeReader"/> will be replaced.
|
||||
/// Adds a custom <see cref="TypeReader" /> to this <see cref="CommandService" /> for the supplied object
|
||||
/// type.
|
||||
/// If <paramref name="type" /> is a <see cref="ValueType" />, a nullable <see cref="TypeReader" /> for the
|
||||
/// value type will also be added.
|
||||
/// If a default <see cref="TypeReader" /> exists for <paramref name="type" />, a warning will be logged and
|
||||
/// the default <see cref="TypeReader" /> will be replaced.
|
||||
/// </summary>
|
||||
/// <param name="type">A <see cref="Type"/> instance for the type to be read.</param>
|
||||
/// <param name="reader">An instance of the <see cref="TypeReader"/> to be added.</param>
|
||||
/// <param name="type">A <see cref="Type" /> instance for the type to be read.</param>
|
||||
/// <param name="reader">An instance of the <see cref="TypeReader" /> to be added.</param>
|
||||
public void AddTypeReader(Type type, TypeReader reader)
|
||||
{
|
||||
if (_defaultTypeReaders.ContainsKey(type))
|
||||
@@ -245,21 +359,31 @@ namespace Discord.Commands
|
||||
AddTypeReader(type, reader, true);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a custom <see cref="TypeReader"/> to this <see cref="CommandService"/> for the supplied object type.
|
||||
/// If <typeparamref name="T"/> is a <see cref="ValueType"/>, a <see cref="NullableTypeReader{T}"/> will also be added.
|
||||
/// Adds a custom <see cref="TypeReader" /> to this <see cref="CommandService" /> for the supplied object
|
||||
/// type.
|
||||
/// If <typeparamref name="T" /> is a <see cref="ValueType" />, a nullable <see cref="TypeReader" /> will
|
||||
/// also be added.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The object type to be read by the <see cref="TypeReader"/>.</typeparam>
|
||||
/// <param name="reader">An instance of the <see cref="TypeReader"/> to be added.</param>
|
||||
/// <param name="replaceDefault">If <paramref name="reader"/> should replace the default <see cref="TypeReader"/> for <typeparamref name="T"/> if one exists.</param>
|
||||
/// <param name="reader">An instance of the <see cref="TypeReader" /> to be added.</param>
|
||||
/// <param name="replaceDefault">
|
||||
/// Defines whether the <see cref="TypeReader"/> should replace the default one for
|
||||
/// <see cref="Type" /> if it exists.
|
||||
/// </param>
|
||||
public void AddTypeReader<T>(TypeReader reader, bool replaceDefault)
|
||||
=> AddTypeReader(typeof(T), reader, replaceDefault);
|
||||
/// <summary>
|
||||
/// Adds a custom <see cref="TypeReader"/> to this <see cref="CommandService"/> for the supplied object type.
|
||||
/// If <paramref name="type"/> is a <see cref="ValueType"/>, a <see cref="NullableTypeReader{T}"/> for the value type will also be added.
|
||||
/// Adds a custom <see cref="TypeReader" /> to this <see cref="CommandService" /> for the supplied object
|
||||
/// type.
|
||||
/// If <paramref name="type" /> is a <see cref="ValueType" />, a nullable <see cref="TypeReader" /> for the
|
||||
/// value type will also be added.
|
||||
/// </summary>
|
||||
/// <param name="type">A <see cref="Type"/> instance for the type to be read.</param>
|
||||
/// <param name="reader">An instance of the <see cref="TypeReader"/> to be added.</param>
|
||||
/// <param name="replaceDefault">If <paramref name="reader"/> should replace the default <see cref="TypeReader"/> for <paramref name="type"/> if one exists.</param>
|
||||
/// <param name="type">A <see cref="Type" /> instance for the type to be read.</param>
|
||||
/// <param name="reader">An instance of the <see cref="TypeReader" /> to be added.</param>
|
||||
/// <param name="replaceDefault">
|
||||
/// Defines whether the <see cref="TypeReader"/> should replace the default one for <see cref="Type" /> if
|
||||
/// it exists.
|
||||
/// </param>
|
||||
public void AddTypeReader(Type type, TypeReader reader, bool replaceDefault)
|
||||
{
|
||||
if (replaceDefault && HasDefaultTypeReader(type))
|
||||
@@ -331,8 +455,20 @@ namespace Discord.Commands
|
||||
}
|
||||
|
||||
//Execution
|
||||
/// <summary>
|
||||
/// Searches for the command.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the command.</param>
|
||||
/// <param name="argPos">The position of which the command starts at.</param>
|
||||
/// <returns>The result containing the matching commands.</returns>
|
||||
public SearchResult Search(ICommandContext context, int argPos)
|
||||
=> Search(context.Message.Content.Substring(argPos));
|
||||
/// <summary>
|
||||
/// Searches for the command.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the command.</param>
|
||||
/// <param name="input">The command string.</param>
|
||||
/// <returns>The result containing the matching commands.</returns>
|
||||
public SearchResult Search(ICommandContext context, string input)
|
||||
=> Search(input);
|
||||
public SearchResult Search(string input)
|
||||
@@ -346,8 +482,30 @@ namespace Discord.Commands
|
||||
return SearchResult.FromError(CommandError.UnknownCommand, "Unknown command.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the command.</param>
|
||||
/// <param name="argPos">The position of which the command starts at.</param>
|
||||
/// <param name="services">The service to be used in the command's dependency injection.</param>
|
||||
/// <param name="multiMatchHandling">The handling mode when multiple command matches are found.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous execution operation. The task result contains the result of the
|
||||
/// command execution.
|
||||
/// </returns>
|
||||
public Task<IResult> ExecuteAsync(ICommandContext context, int argPos, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception)
|
||||
=> ExecuteAsync(context, context.Message.Content.Substring(argPos), services, multiMatchHandling);
|
||||
/// <summary>
|
||||
/// Executes the command.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the command.</param>
|
||||
/// <param name="input">The command string.</param>
|
||||
/// <param name="services">The service to be used in the command's dependency injection.</param>
|
||||
/// <param name="multiMatchHandling">The handling mode when multiple command matches are found.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous execution operation. The task result contains the result of the
|
||||
/// command execution.
|
||||
/// </returns>
|
||||
public async Task<IResult> ExecuteAsync(ICommandContext context, string input, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception)
|
||||
{
|
||||
services = services ?? EmptyServiceProvider.Instance;
|
||||
|
||||
Reference in New Issue
Block a user