Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 17a4af7
Author: Still Hsu <341464@gmail.com>
Date:   Tue May 29 17:15:10 2018 +0800

    Add documentation for new API version & few events

commit f4fb027
Merge: d74c528 3acf2a9
Author: Still Hsu <341464@gmail.com>
Date:   Tue May 29 08:25:41 2018 +0800

    Merge remote-tracking branch 'upstream/dev' into docs/faq-n-patches-offline

commit 3acf2a9
Author: HelpfulStranger999 <helpfulstranger999@gmail.com>
Date:   Mon May 28 14:59:30 2018 -0500

    Refactors readMessages, fixing from discord-net#1033 (discord-net#1075)

commit 513a489
Author: Christopher F <foxbot@protonmail.com>
Date:   Mon May 28 15:45:42 2018 -0400

    codefix: add VoiceAPIVersion constant to DiscordConfig

commit 9ba38d7
Author: Christopher F <foxbot@protonmail.com>
Date:   Mon May 28 15:35:59 2018 -0400

    api: upgrade audio client to VoiceWS v3

commit 64d8938
Author: Christopher F <foxbot@protonmail.com>
Date:   Mon May 28 15:25:46 2018 -0400

    fix: Discord does not always send the member on VOICE_STATE_UPDATE

    some guilds aren't on g250k yet? not sure

commit aeb3095
Author: FiniteReality <digpoealternate@gmail.com>
Date:   Mon May 28 17:48:38 2018 +0100

    Remove Debug.Print call causing tests to fail

    Forgot to hit save properly... Whoops.

commit a718a7d
Author: Christopher F <foxbot@protonmail.com>
Date:   Mon May 28 12:45:49 2018 -0400

    cleanup: Remove ChannelHelper#IsNsfw

    Closes discord-net#1074

    This code was not referenced anywhere in the active codebase.

commit 0c7cb73
Author: FiniteReality <digpoealternate@gmail.com>
Date:   Mon May 28 17:41:05 2018 +0100

    Fix permission-related ViewChannel tests

commit 415e2f7
Author: FiniteReality <digpoealternate@gmail.com>
Date:   Mon May 28 17:14:18 2018 +0100

    Fix analyzer warnings with tests

    Use (actual, expected) format for Assert.Equal, fixes analyzer warnings

commit b004260
Author: FiniteReality <digpoealternate@gmail.com>
Date:   Mon May 28 17:13:59 2018 +0100

    Move RpcCategoryChannel into the correct project

commit 683b3f2
Author: FiniteReality <digpoealternate@gmail.com>
Date:   Mon May 28 17:12:28 2018 +0100

    Mark ChannelHelper.IsNsfw Obsolete

    Discord no longer treats channels prefixed with 'nsfw' as NSFW,
    so we no longer need to have this check.

commit d74c528
Merge: 341b958 237ad0f
Author: Still Hsu <341464@gmail.com>
Date:   Mon May 28 11:48:47 2018 +0800

    Merge branch 'dev' into docs/faq-n-patches-offline

commit 237ad0f
Author: Christopher F <foxbot@protonmail.com>
Date:   Sun May 27 18:00:51 2018 -0400

    Revert "fix: Properly rethrow exceptions in SocketGuild audio client"

    This reverts commit adf4da1.

    Someone hasn't written c# in a while

commit adf4da1
Author: Christopher F <foxbot@protonmail.com>
Date:   Sun May 27 17:56:14 2018 -0400

    fix: Properly rethrow exceptions in SocketGuild audio client

commit c0c565f
Author: Christopher F <foxbot@protonmail.com>
Date:   Sun May 27 16:45:54 2018 -0400

    retain fallback case for if user is still null

commit 8fb2c71
Author: Christopher F <foxbot@protonmail.com>
Date:   Sun May 27 16:37:17 2018 -0400

    Add new member objects to events

commit 341b958
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 27 19:01:04 2018 +0800

    Add documentation

commit 2df635e
Merge: 180b20d 9995cab
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 27 18:25:51 2018 +0800

    Merge pull request #1 from Chris-Johnston/better-documentation-for-quotation-mark-aliases

    Improve XML docs for commands quotation mark aliases feature

commit 180b20d
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 27 18:19:20 2018 +0800

    Add documentation for new INestedChannel

commit e9f72b6
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 27 18:18:52 2018 +0800

    Fix missing service provider in example

commit 9995cab
Merge: a8d3031 1a146af
Author: Chris Johnston <chris@thejohnstons.net>
Date:   Sun May 27 01:11:17 2018 -0700

    Merge branch 'docs/faq-n-patches-offline' into better-documentation-for-quotation-mark-aliases

commit a8d3031
Author: Chris Johnston <chris@thejohnstons.net>
Date:   Sat May 26 23:32:40 2018 -0700

    Add explanation that if " is removed then it wont work

commit cb7c6d3
Author: Chris Johnston <chris@thejohnstons.net>
Date:   Sat May 26 23:29:32 2018 -0700

    Add reference to CommandServiceConfig from the util docs'

commit 110b975
Author: Chris Johnston <chris@thejohnstons.net>
Date:   Sat May 26 23:15:01 2018 -0700

    Add more XML comments to quotation mark alias map stuff, including an example

commit 1a146af
Merge: cb57ada a06e212
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 27 11:25:10 2018 +0800

    Merge branch 'dev' into docs/faq-n-patches-offline

commit a06e212
Author: Chris Johnston <chris@thejohnstons.net>
Date:   Sat May 26 11:15:09 2018 -0700

    Fix ChannelPermissions Modify parameter to be correct default value (discord-net#1003)

    * fix channel permissions modify parameter to use nullable boolean, correct default value

    * Add general tests for the ChannelPermissions.Modify method to test default values

    * remove unused cast in tests

    * add guildpermission modify no param tests

    * Add no-param modify tests for OverwritePermissions

    * fix inconsistent parameters in GuildPermissions cstr

    * Adjust formatting of methods and cstrs with many parameters

    * remove temp file that was included. no idea what that is

    * Fix System dependency

    I should really stop fixing merge conflicts in the github website.

commit f9cbff5
Author: Chris Johnston <chris@thejohnstons.net>
Date:   Sat May 26 11:06:35 2018 -0700

    Fix discord-net#995, Move Category Implementation from IGuildChannel to INestedChannel (discord-net#1004)

    * Fix discord-net#995 ICategoryChannel.CategoryID throws NotSupportedException

    * Add tests

    * change run mode of TestChannelCategories

    * Add throw for GetCategoryAsync

    * Add xml doc explaining why exception is thrown

    * Add test coverage for text and voice channel categories

    * initial implementation of INestedChannel

    * more implementation of INestedChannel design

    * Add case in RestChannel Create for Category type

    * set the CategoryID for RestVoiceChannel

    * rewrite channel category tests to work with existing pattern

    * remove outdated todo

    * Make IVoiceChannel implement INestedChannel

    * remove redundant interface implementation

    * Add c#7 feature from feedback

    * Remove redundant GetCategoryAsync methods from socket entities

    * Added configureawait to async methods

    * change signature of interface GetCategoryAsync

    * Add check for cachemode in rest channel GetCategory

    * remove redundant IGuildChannel interface from ITextChannel and IVoiceChannel

commit 4d8764e
Author: FiniteReality <digpoealternate@gmail.com>
Date:   Sat May 26 14:11:49 2018 +0100

    Refactor RoleInfo types into separate classes

    - Fixes indentation with a few files (looks like a bad copy+paste job)
    - Renames RoleInfo to RoleEditInfo
    - Moves RoleInfo from MemberRoleAuditLogData into its own class

    All of this should improve docs.

commit cb57ada
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 26 21:03:07 2018 +0800

    Add partial documentation for audit log objects

commit afda0cd
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 26 20:47:21 2018 +0800

    Add documentation for some REST-based objects

commit 098ead9
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 26 16:33:38 2018 +0800

    Add partial documentation for audit log impl

commit 5d1621a
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 26 16:06:20 2018 +0800

    Fix xml docs error

commit 596b47e
Merge: 3f572cc fa759a2
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 26 15:54:08 2018 +0800

    Merge branch 'dev' into docs/faq-n-patches-offline

commit 3f572cc
Merge: 73ebc02 a998302
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 26 15:32:38 2018 +0800

    Merge branch 'docs/faq-n-patches-offline' of https://github.com/Still34/Discord.Net into docs/faq-n-patches-offline

commit 73ebc02
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 26 15:32:23 2018 +0800

    Fix light theme link color

commit fa759a2
Author: Chris Johnston <chris@thejohnstons.net>
Date:   Fri May 25 06:38:59 2018 -0700

    Remove Build Warnings for Obsolete Guild Permission Read Messages (discord-net#1067)

    - Replaces the usages of `ReadMessages` with `ViewChannel`
    - Renames the read message parameters of `GuildPermissions#Modify` to be view channel as well

commit bbbac85
Author: Hawx <Hawxy@users.noreply.github.com>
Date:   Fri May 25 20:14:28 2018 +0800

    Update Dependencies and support NS2.0 builds (discord-net#1046)

    * Update deps, fix test warnings.

    * Support ns2.0

    * Fix typo

    * Remove ns1.1 support

    * Net.Http and Net.Websockets.Client are not needed in ns2.0

    * Move to net46 per volt

    * Remove ns1.3 constants

commit 5f084ad
Author: HelpfulStranger999 <helpfulstranger999@gmail.com>
Date:   Thu May 24 19:17:19 2018 -0500

    Deprecates ReadMessages, introduces ViewChannel (discord-net#1033)

    * Deprecates ReadMessages, introduces ViewChannel

    * Adds period and comma somehow missed

commit bc6009e
Author: Still Hsu <341464@gmail.com>
Date:   Fri May 25 08:08:51 2018 +0800

    Implement IMessageChannel#DeleteMessageAsync (discord-net#996)

    * Implement DeleteMessageAsync

    * Refer to MessageHelper instead of duplicating call

    * Fix refactor error

commit cee71ef
Author: Chris Johnston <chris@thejohnstons.net>
Date:   Thu May 24 17:07:37 2018 -0700

    Add support for parsing multiple types of quotation marks in commands, Fix discord-net#942 (discord-net#943)

    * Add ability to support different types of quotation marks

    * Added normal quotation mark to list of aliases, removed single quote mark

    * clean up leftover changes from testing

    * change quotation mark parsing to use a map of matching pairs

    * remove commented out code

    * Fix conventions of the command parser utility functions

    * change storage type of alias dictionary to be IReadOnlyDictionary

    * revert type of CommandServiceConfig QuotationMarkAliasMap to Dictionary

    * minor formatting changes to CommandParser

    * remove unnecessary whitespace

    * Move aliases outside of CommandInfo class

    * copy IReadOnlyDictionary to ImmutableDictionary

    * minor syntax changes in CommandServiceConfig

    * add newline before namespace for consistency

    * newline formatting tweak

    * simplification of GetMatch method for CommandParser

    * add more quote unicode punctuation pairs

    * add check for null value when building ImmutableDictionary

    * Move default alias map into a separate source file

    * Ensure that the collection passed into command service is not null

commit b52af7a
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Fri May 25 01:59:32 2018 +0200

    Add a dedicated TimeSpan reader so it doesn't suck (discord-net#1005)

    * Add a dedicated TimeSpan reader so it doesn't suck

    * Pass input as lower case

commit c275e57
Author: o Acid Chicken (硫硫▒~E▒▒▒~O) <root@acid-chicken.com>
Date:   Thu May 24 19:52:25 2018 -0400

    Add support casting System.Drawing.Color to Discord.Color

    commit fa33034
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Sun Apr 29 13:50:56 2018 +0900

        Use built-in symbol

        refs: discord-net#1043 (comment)

    commit 27ea826
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Sun Apr 29 11:29:31 2018 +0900

        Add support casting System.Drawing.Color to Discord.Color

    commit 1ab9de2
    Merge: f5bb99c a4d1e2b
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Sun Apr 29 10:16:46 2018 +0900

        Merge remote-tracking branch 'upstream/dev' into dev

    commit f5bb99c
    Merge: 3be8e40 b8b59d9
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Tue Apr 10 11:07:36 2018 +0900

        Merge remote-tracking branch 'upstream/dev' into dev

    commit 3be8e40
    Merge: c692306 9d77a3c
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Sun Jan 7 15:05:31 2018 +0900

        Merge remote-tracking branch 'upstream/dev' into dev

    commit c692306
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Sat Nov 11 10:49:00 2017 +0900

        Add target of the internal fields

    commit 2d08f9a
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Sat Nov 11 10:17:42 2017 +0900

        Add some more extension

    commit 4f19b83
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Sat Nov 11 01:19:11 2017 +0900

        Add naming rules

    commit af756cd
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Sat Nov 11 00:35:30 2017 +0900

        Add basic .NET style rules

    commit 503ece5
    Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
    Date:   Fri Nov 10 22:36:52 2017 +0900

        Add EditorConfig

commit 5023357
Author: Christopher F <foxbot@protonmail.com>
Date:   Thu May 24 19:36:33 2018 -0400

    codefix discord-net#1020: RequestOptions should always be sorted last

commit bf5275e
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Thu May 24 19:36:00 2018 -0400

    Add ability to specify parameters on channel creation (discord-net#1020)

    commit 07bca5b
    Author: Joe4evr <jii.geugten@gmail.com>
    Date:   Fri Apr 6 09:44:50 2018 +0200

        Add ability to specify parameters on channel creation

commit 0ba8b06
Author: HelpfulStranger999 <helpfulstranger999@gmail.com>
Date:   Thu May 24 19:23:44 2018 -0400

    Makes text parameter of sending messages optional (discord-net#1042)

    commit 114e5b4
    Author: HelpfulStranger999 <helpfulstranger999@gmail.com>
    Date:   Sat Apr 28 19:08:35 2018 -0500

        Fixes lack of default value for tts

    commit 1fd8c70
    Author: HelpfulStranger999 <helpfulstranger999@gmail.com>
    Date:   Sat Apr 28 15:21:11 2018 -0500

        Makes text parameter of sending messages optional

commit 79811d0
Author: HelpfulStranger999 <helpfulstranger999@gmail.com>
Date:   Thu May 24 17:35:38 2018 -0500

    Paginate reactions - solved discord-net#1007 (discord-net#1022)

    * Cleaned up and refactored slightly

    * Resolves discord-net#971

    * Adds support for default avatars and resolves discord-net#971

    * Amendment

    * Final amendment

    * Paginating reactions

    * Amendments based on feedback

    * Further amendment based on review

    * Final(?) amendment

    * Removes default limit and after user id

    * Removes fromUserId; cleans up model creation; replaces function with individual parameters

commit a998302
Author: Still Hsu <341464@gmail.com>
Date:   Tue May 22 10:15:49 2018 +0800

    Add event docs

    - MessageReceived
    - ChannelUpdated/Destroyed/Created

commit dece19d
Merge: fdaa689 e764daf
Author: Still Hsu <341464@gmail.com>
Date:   Mon May 21 11:47:47 2018 +0800

    Merge branch 'dev' into docs/faq-n-patches-offline

commit fdaa689
Author: Still Hsu <341464@gmail.com>
Date:   Wed May 9 06:04:59 2018 +0800

    Add explanation for RunMode

commit ea82c25
Author: Still Hsu <341464@gmail.com>
Date:   Tue May 8 16:30:48 2018 +0800

    Initial proofread of the articles

commit 124f1a2
Merge: 2555721 97c8931
Author: Still Hsu <341464@gmail.com>
Date:   Tue May 8 05:02:01 2018 +0800

    Merge branch 'dev' into docs/faq-n-patches-offline

commit 2555721
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 16:11:19 2018 +0800

    Add details to SpotifyGame

commit c7b236d
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 15:58:23 2018 +0800

    Add more IGuild docs

commit 1bb06cc
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 15:40:31 2018 +0800

    Replace all langword placements with code block

commit ac47d84
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 15:22:17 2018 +0800

    Replace langword null to code block null instead

    - Because DocFX sucks at rendering langword

commit 0b15bbc
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 15:20:34 2018 +0800

    Add XML docs

commit 65d4e43
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 06:57:53 2018 +0800

    Add BaseSocketClient docs

commit 8f64c04
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 06:37:55 2018 +0800

    Replace note block

commit d8bb9e7
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 06:31:50 2018 +0800

    Add warning for bulk-delete endpoint

commit adae5ff
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 06:07:28 2018 +0800

    Fix missing Username prop

commit 3e59197
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 06:01:34 2018 +0800

    Add properties examples to overwrite

commit 0ad66f6
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 04:55:15 2018 +0800

    Fix minor consistencies & redundant impl

commit 124efdf
Author: Still Hsu <341464@gmail.com>
Date:   Sun May 6 04:40:14 2018 +0800

    XML Docs

commit 3aa5d36
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 18:22:46 2018 +0800

    Add 'last modified' plugin

    Source: https://github.com/Still34/DocFx.Plugin.LastModified
    Licensed under MIT License

commit 2014870
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 15:57:40 2018 +0800

    Fix letter-casing for files

commit f27d659
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 15:50:00 2018 +0800

    Document exposed TypeReaders

commit 5a824a5
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 15:44:15 2018 +0800

    Add missing exceptions

commit c2de0c0
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 15:40:16 2018 +0800

    Fix seealso for preconditions and add missing descriptions

commit 3a7d7ee
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 15:36:22 2018 +0800

    Minor fixes in documentations
    + Fix unescaped '<'
    + Fix typo

commit 45839bd
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 15:29:47 2018 +0800

    Add XML Docs

commit 9e62546
Merge: aea0678 bb4bb13
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 14:48:13 2018 +0800

    Merge branch 'dev' into docs/faq-n-patches-offline

commit aea0678
Merge: 27dc483 9ddd709
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 13:51:07 2018 +0800

    Merge branch 'docs/faq-n-patches-offline' of https://github.com/Still34/Discord.Net into docs/faq-n-patches-offline

commit 27dc483
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 13:50:27 2018 +0800

    Add XML Docs

commit baa8beb
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 13:49:42 2018 +0800

    Add XML Docs

commit 089f97a
Author: Still Hsu <341464@gmail.com>
Date:   Sat May 5 13:43:04 2018 +0800

    Add details regarding userbot support

commit 9ddd709
Merge: f197174 7cfed7f
Author: Still Hsu <341464@gmail.com>
Date:   Fri May 4 09:37:04 2018 +0800

    Merge branch 'dev' into docs/faq-n-patches-offline

commit f197174
Author: Still Hsu <341464@gmail.com>
Date:   Fri May 4 09:36:53 2018 +0800

    Fix embed docs consistency

commit 157acc4
Author: Still Hsu <341464@gmail.com>
Date:   Thu May 3 23:03:35 2018 +0800

    Add tag examples

commit 57ea571
Author: Still Hsu <341464@gmail.com>
Date:   Thu May 3 22:48:33 2018 +0800

    Fix sample link & add missing pictures

commit 6769c37
Author: Still Hsu <341464@gmail.com>
Date:   Thu May 3 22:39:26 2018 +0800

    Compress some assets & add OAuth2 URL generator
  • Loading branch information
Still Hsu committed May 29, 2018
1 parent 25fdf29 commit 15f09db
Show file tree
Hide file tree
Showing 129 changed files with 2,121 additions and 678 deletions.
8 changes: 1 addition & 7 deletions Discord.Net.targets
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
<PropertyGroup Condition=" '$(BuildNumber)' != '' And $(IsTagBuild) != 'true' ">
<VersionSuffix Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' == '' ">build-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' Or '$(TargetFramework)' == 'net45' ">
<DefineConstants>$(DefineConstants);FILESYSTEM;DEFAULTUDPCLIENT;DEFAULTWEBSOCKET</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>$(DefineConstants);FORMATSTR;UNIXTIME;MSTRYBUFFER;UDPDISPOSE</DefineConstants>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<NoWarn>$(NoWarn);CS1573;CS1591</NoWarn>
<WarningsAsErrors>true</WarningsAsErrors>
Expand Down
17 changes: 15 additions & 2 deletions docs/_template/light-dark-theme/styles/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ body {
overflow: visible;
}

/* links */

a:active, a:hover, a:visited {
color: #0078d7;
}

a {
color: #0050c5;
cursor: pointer;
text-decoration: none;
word-wrap: break-word;
}

/* code */

code {
color: #222f3d;
background-color: #f9f9f9;
color: #3b5269;
background-color: #ececec;
border-radius: 4px;
padding: 3px 7px;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"globalMetadata": {
"_appTitle": "Discord.Net Documentation",
"_appFooter": "Discord.Net (c) 2015-2018 2.0.0-beta",
"_enableSearch": true,
"_enableSearch": true
},
"noLangKeyword": false,
"xrefService": [
Expand Down
10 changes: 6 additions & 4 deletions docs/guides/commands/samples/command_handler.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
public class CommandHandle
public class CommandHandler
{
private readonly DiscordSocketClient _client;
private readonly CommandService _commands;
private readonly IServiceProvider _services;

public CommandHandle(DiscordSocketClient client)
public CommandHandler(IServiceProvider services)
{
_client = client;
_commands = new CommandService();
_services = services;
_commands = services.GetRequiredService<CommandService>();
_client = services.GetRequiredService<DiscordSocketClient>();
}

public async Task InstallCommandsAsync()
Expand Down
2 changes: 1 addition & 1 deletion samples/02_commands_framework/02_commands_framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0-preview1-final" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Analyzers/Discord.Net.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFramework>netstandard1.3</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Commands\Discord.Net.Commands.csproj" />
Expand Down
34 changes: 28 additions & 6 deletions src/Discord.Net.Commands/CommandParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -13,8 +14,7 @@ private enum ParserPart
Parameter,
QuotedParameter
}

public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, IServiceProvider services, string input, int startPos)
public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, ICommandContext context, bool ignoreExtraArgs, IServiceProvider services, string input, int startPos, IReadOnlyDictionary<char, char> aliasMap)
{
ParameterInfo curParam = null;
StringBuilder argBuilder = new StringBuilder(input.Length);
Expand All @@ -24,7 +24,27 @@ public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, IComma
var argList = ImmutableArray.CreateBuilder<TypeReaderResult>();
var paramList = ImmutableArray.CreateBuilder<TypeReaderResult>();
bool isEscaping = false;
char c;
char c, matchQuote = '\0';

// local helper functions
bool IsOpenQuote(IReadOnlyDictionary<char, char> dict, char ch)
{
// return if the key is contained in the dictionary if it is populated
if (dict.Count != 0)
return dict.ContainsKey(ch);
// or otherwise if it is the default double quote
return c == '\"';
}

char GetMatch(IReadOnlyDictionary<char, char> dict, char ch)
{
// get the corresponding value for the key, if it exists
// and if the dictionary is populated
if (dict.Count != 0 && dict.TryGetValue(c, out var value))
return value;
// or get the default pair of the default double quote
return '\"';
}

for (int curPos = startPos; curPos <= endPos; curPos++)
{
Expand Down Expand Up @@ -74,9 +94,11 @@ public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, IComma
argBuilder.Append(c);
continue;
}
if (c == '\"')

if (IsOpenQuote(aliasMap, c))
{
curPart = ParserPart.QuotedParameter;
matchQuote = GetMatch(aliasMap, c);
continue;
}
curPart = ParserPart.Parameter;
Expand All @@ -97,7 +119,7 @@ public static async Task<ParseResult> ParseArgsAsync(CommandInfo command, IComma
}
else if (curPart == ParserPart.QuotedParameter)
{
if (c == '\"')
if (c == matchQuote)
{
argString = argBuilder.ToString(); //Remove quotes
lastArgEndPos = curPos + 1;
Expand Down
9 changes: 7 additions & 2 deletions src/Discord.Net.Commands/CommandService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down Expand Up @@ -38,6 +38,7 @@ public class CommandService
internal readonly RunMode _defaultRunMode;
internal readonly Logger _cmdLogger;
internal readonly LogManager _logManager;
internal readonly IReadOnlyDictionary<char, char> _quotationMarkAliasMap;

/// <summary>
/// Represents all modules loaded within <see cref="CommandService" />.
Expand Down Expand Up @@ -73,6 +74,7 @@ public CommandService(CommandServiceConfig config)
_ignoreExtraArgs = config.IgnoreExtraArgs;
_separatorChar = config.SeparatorChar;
_defaultRunMode = config.DefaultRunMode;
_quotationMarkAliasMap = (config.QuotationMarkAliasMap ?? new Dictionary<char, char>()).ToImmutableDictionary();
if (_defaultRunMode == RunMode.Default)
throw new InvalidOperationException("The default run mode cannot be set to Default.");

Expand All @@ -93,6 +95,10 @@ public CommandService(CommandServiceConfig config)
_defaultTypeReaders[typeof(Nullable<>).MakeGenericType(type)] = NullableTypeReader.Create(type, _defaultTypeReaders[type]);
}

var tsreader = new TimeSpanTypeReader();
_defaultTypeReaders[typeof(TimeSpan)] = tsreader;
_defaultTypeReaders[typeof(TimeSpan?)] = NullableTypeReader.Create(typeof(TimeSpan), tsreader);

_defaultTypeReaders[typeof(string)] =
new PrimitiveTypeReader<string>((string x, out string y) => { y = x; return true; }, 0);

Expand Down Expand Up @@ -447,7 +453,6 @@ public Task<IResult> ExecuteAsync(ICommandContext context, int argPos, IServiceP
public async Task<IResult> ExecuteAsync(ICommandContext context, string input, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception)
{
services = services ?? EmptyServiceProvider.Instance;

var searchResult = Search(context, input);
if (!searchResult.IsSuccess)
return searchResult;
Expand Down
22 changes: 21 additions & 1 deletion src/Discord.Net.Commands/CommandServiceConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;

namespace Discord.Commands
{
Expand Down Expand Up @@ -34,8 +35,27 @@ public class CommandServiceConfig
public bool ThrowOnError { get; set; } = true;

/// <summary>
/// Gets or sets whether extra parameters should be ignored.
/// Collection of aliases for matching pairs of string delimiters.
/// The dictionary stores the opening delimiter as a key, and the matching closing delimiter as the value.
/// If no value is supplied <see cref="QuotationAliasUtils.GetDefaultAliasMap"/> will be used, which contains
/// many regional equivalents.
/// Only values that are specified in this map will be used as string delimiters, so if " is removed then
/// it won't be used.
/// If this map is set to null or empty, the default delimiter of " will be used.
/// </summary>
/// <example>
/// <code language="C#">
/// QuotationMarkAliasMap = new Dictionary&lt;char, char%gt;()
/// {
/// {'\"', '\"' },
/// {'“', '”' },
/// {'「', '」' },
/// }
/// </code>
/// </example>
public Dictionary<char, char> QuotationMarkAliasMap { get; set; } = QuotationAliasUtils.GetDefaultAliasMap;

/// <summary> Determines whether extra parameters should be ignored. </summary>
public bool IgnoreExtraArgs { get; set; } = false;
}
}
10 changes: 7 additions & 3 deletions src/Discord.Net.Commands/Discord.Net.Commands.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../Discord.Net.targets" />
<PropertyGroup>
<AssemblyName>Discord.Net.Commands</AssemblyName>
<RootNamespace>Discord.Commands</RootNamespace>
<Description>A Discord.Net extension adding support for bot commands.</Description>
<TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net46;netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.3;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions src/Discord.Net.Commands/Info/CommandInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Discord.Commands.Builders;
using Discord.Commands.Builders;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down Expand Up @@ -172,7 +172,8 @@ public async Task<ParseResult> ParseAsync(ICommandContext context, int startInde
return ParseResult.FromError(preconditionResult);

string input = searchResult.Text.Substring(startIndex);
return await CommandParser.ParseArgsAsync(this, context, services, input, 0).ConfigureAwait(false);

return await CommandParser.ParseArgsAsync(this, context, _commandService._ignoreExtraArgs, services, input, 0, _commandService._quotationMarkAliasMap).ConfigureAwait(false);
}

public Task<IResult> ExecuteAsync(ICommandContext context, ParseResult parseResult, IServiceProvider services)
Expand Down
4 changes: 2 additions & 2 deletions src/Discord.Net.Commands/PrimitiveParsers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;

Expand Down Expand Up @@ -29,7 +29,7 @@ static IReadOnlyDictionary<Type, Delegate> CreateParsers()
parserBuilder[typeof(decimal)] = (TryParseDelegate<decimal>)decimal.TryParse;
parserBuilder[typeof(DateTime)] = (TryParseDelegate<DateTime>)DateTime.TryParse;
parserBuilder[typeof(DateTimeOffset)] = (TryParseDelegate<DateTimeOffset>)DateTimeOffset.TryParse;
parserBuilder[typeof(TimeSpan)] = (TryParseDelegate<TimeSpan>)TimeSpan.TryParse;
//parserBuilder[typeof(TimeSpan)] = (TryParseDelegate<TimeSpan>)TimeSpan.TryParse;
parserBuilder[typeof(char)] = (TryParseDelegate<char>)char.TryParse;
return parserBuilder.ToImmutable();
}
Expand Down
35 changes: 35 additions & 0 deletions src/Discord.Net.Commands/Readers/TimeSpanTypeReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Globalization;
using System.Threading.Tasks;

namespace Discord.Commands
{
internal class TimeSpanTypeReader : TypeReader
{
private static readonly string[] _formats = new[]
{
"%d'd'%h'h'%m'm'%s's'", //4d3h2m1s
"%d'd'%h'h'%m'm'", //4d3h2m
"%d'd'%h'h'%s's'", //4d3h 1s
"%d'd'%h'h'", //4d3h
"%d'd'%m'm'%s's'", //4d 2m1s
"%d'd'%m'm'", //4d 2m
"%d'd'%s's'", //4d 1s
"%d'd'", //4d
"%h'h'%m'm'%s's'", // 3h2m1s
"%h'h'%m'm'", // 3h2m
"%h'h'%s's'", // 3h 1s
"%h'h'", // 3h
"%m'm'%s's'", // 2m1s
"%m'm'", // 2m
"%s's'", // 1s
};

public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
{
return (TimeSpan.TryParseExact(input.ToLowerInvariant(), _formats, CultureInfo.InvariantCulture, out var timeSpan))
? Task.FromResult(TypeReaderResult.FromSuccess(timeSpan))
: Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Failed to parse TimeSpan"));
}
}
}
Loading

0 comments on commit 15f09db

Please sign in to comment.