Commit Graph

33 Commits

Author SHA1 Message Date
Joe4evr
6d3010065f Allow setting IgnoreExtraArgs on an individual basis (#998)
* Allow setting IgnoreExtraArgs on an individual basis

* Remove passing in the flag as a separate parameter

* VS plz

* Push the RunMode setting out to its own attribute, because fox wants consistency.

Bonus: Removes the need for that godawful 'RunMode.Default'.

* Revert previous commit

* Fox doesn't like module-wide switches 😒
2018-04-29 11:10:00 -04:00
Paulo
6b7c6e9667 Add new overload for AddTypeReader (#1009) 2018-03-30 15:40:43 -04:00
Joe4evr
170a2e00bd Resolve #936 (#941)
* Resolve #936

* Remember to not search *only* typereaders for primitives 😒
2018-03-08 16:09:34 -05:00
Alex Gravely
4edbd8d4b9 Allow nested ModuleBase classes to be built when declared from non-module classes. (#969)
* Allow modules to be built regardless of their declaring type.

* Need to exclude submodules.
2018-03-04 13:15:00 -05:00
Christopher F
b1eaa44021 Don't attempt to load types with generic parameters as a module
This fixes an issue where custom ModuleBases that contained a generic
parameter would be loaded as a module - only to fail when trying to be
built.

Realistically, ModuleBases _should_ be abstract - but it was still a bug
that we allowed them to be included as a module.
2018-02-26 19:35:43 -05:00
Christopher F
bb8ebc13d2 Add callback method for when a module class has been added (#934)
commit 5b047bf02b4299f34172cac05dc7e4a84ecc108c
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Fri Feb 2 22:22:00 2018 +0100

    [feature/OnModuleAdded] Quickstart fixes (#946)

    * Quickstart: fix minor derp

    * Other overdue fixes

commit bd3e9eee943b9092cc45217b19ff95bae359f888
Author: Christopher F <computerizedtaco@gmail.com>
Date:   Sat Jan 27 16:51:18 2018 -0500

    Resort usings in ModuleBase

commit 8042767579b337fdae7fe48e0a6ea2f007aef440
Author: Christopher F <computerizedtaco@gmail.com>
Date:   Sat Jan 27 16:41:39 2018 -0500

    Clean up removed owned IServiceProvider

commit 30066cb102ffbd65906ead72a377811aa501abba
Author: Christopher F <computerizedtaco@gmail.com>
Date:   Sat Jan 27 16:37:22 2018 -0500

    Remove redundant try-catch around OnModuleBuilding invocation

    If this exception is going to be rethrown, there's no reason to include
    a try-catch.

commit 60c7c31d4476c498a97ae0536ec5792f08efb89b
Author: Christopher F <computerizedtaco@gmail.com>
Date:   Sat Jan 27 16:36:27 2018 -0500

    Include the ModuleBuilder in OnModuleBuilding

    This allows modules hooking into OnModuleBuilding method to mutate
    theirselves at runtime.

commit b6a9ff57860ff3bddbad7ca850fd331529cb8e6e
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Mon Jan 22 13:17:14 2018 +0100

    #DERP

commit f623d19c68c5642a44898a561f77ed82d53fd103
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Mon Jan 22 13:15:31 2018 +0100

    Resolution for #937 because it's literally 4 lines of code

commit 8272c9675b0d63b4100aaf57f5067d635b68f5e6
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Mon Jan 22 11:39:28 2018 +0100

    Re-adjust quickstart

commit e30b9071351b69baa30a93a4851516dca9ea43cf
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Mon Jan 22 11:35:08 2018 +0100

    Undo experimental changes, request IServiceProvider instance everywhere instead

commit ad7e0a46c8709e845dfacdc298a893e22dc11567
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Fri Jan 19 03:40:27 2018 +0100

    Fix quickstart leftover from previous draft

commit e3349ef3d400bb3ad8cb28dd4234d5316a80bcc4
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Fri Jan 19 03:33:46 2018 +0100

    Doc comment on items

commit 81bd9111faaf98a52679daae863ab04dce96e63e
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Fri Jan 19 03:16:44 2018 +0100

    Add comment about the ServiceProviderFactory in the quickstart

commit 72b5e6c8a149d8e989b46351965daa14f8ca318c
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Fri Jan 19 03:10:40 2018 +0100

    Remove superfluous comments, provide simpler alternative for setting the ServiceProvider.

commit 74b17b0e04e2c413397a2e1b66ff814615326205
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Tue Jan 16 18:06:28 2018 +0100

    Experimental change for feedback

commit 7b100e99bb119be190006d1cd8e403776930e401
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Mon Jan 15 23:34:06 2018 +0100

    * Make the service provider parameters required

    * Adjust quickstart guide to reflect changes

commit 7f1b792946ac6b950922b06178aa5cc37d9f4144
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Mon Jan 15 20:04:37 2018 +0100

    I..... missed one.

commit 031b289d80604666dde62619e521af303203d48d
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Mon Jan 15 20:02:20 2018 +0100

    Rename method to more intuitive 'OnModuleBuilding'

commit 9a166ef1d0baecd21e4e5b965e2ac364feddbe2e
Author: Joe4evr <jii.geugten@gmail.com>
Date:   Mon Jan 15 19:09:10 2018 +0100

    Add callback method for when a module class has been added to the CommandService.
2018-02-18 19:16:38 -05:00
Izumemori
9c81ab9fe4 changed NameAttribute to work for parameter (#765) 2017-08-29 16:45:30 -04:00
Finite Reality
d2afb06942 Make the "cannot be loaded" warning fire correctly (#729)
Why am I such a bad programmer? Maybe I'm just bad with git. Maybe I'm
just bad in general. Maybe I should resign from programming.
2017-07-05 20:19:09 -03:00
Joe4evr
b6dcc9e8d8 Add back the case for ParameterPreconditions (#735) 2017-07-05 20:13:49 -03:00
RogueException
14dfc48df3 Style cleanup 2017-06-29 19:44:32 -03:00
Finite Reality
74f6a4b392 Allow commands to return a Task<RuntimeResult> (#466)
* Allow commands to return a Task<RuntimeResult>

This allows bot developers to centralize command result logic by
using result data whether the command as successful or not.

Example usage:
```csharp
var _result = await Commands.ExecuteAsync(context, argPos);
if (_result is RuntimeResult result)
{
    await message.Channel.SendMessageAsync(result.Reason);
}
else if (!_result.IsSuccess)
{
    // Previous error handling
}
```

The RuntimeResult class can be subclassed too, for example:
```csharp
var _result = await Commands.ExecuteAsync(context, argPos);
if (_result is MySubclassedResult result)
{
    var builder = new EmbedBuilder();
    for (var pair in result.Data)
    {
        builder.AddField(pair.Key, pair.Value, true);
    }
    await message.Channel.SendMessageAsync("", embed: builder);
}
else if (_result is RuntimeResult result)
{
    await message.Channel.SendMessageAsync(result.Reason);
}
else if (!_result.IsSuccess)
{
    // Previous error handling
}
```

* Make RuntimeResult's ctor protected

* Make RuntimeResult abstract

It never really made sense to have it instantiable in the first place,
frankly.
2017-06-29 19:21:05 -03:00
Finite Reality
b96748f9c3 Allow arbitrary attributes to be added to commands (#458)
* Allow arbitrary attributes to be added to commands

I still don't approve adding type info back into commands, so
I decided to use this solution for allowing arbitrary attributes to be
added to commands.

Add attributes property to ParameterBuilder

Add Attributes properties to info types

* Why on earth git

* Add using for system so that Attribute can be used
2017-06-29 18:30:26 -03:00
Finite Reality
032aba9129 Update commands with C#7 features (#689)
* C#7 features in commands, CommandInfo in ModuleBase

* Update TypeReaders with C#7 features and IServiceProvider

* Add best-choice command selection to CommandService

* Normalize type reader scores correctly

* Fix logic error and rebase onto dev

* Change GetMethod for SetMethod in ReflectionUtils

Should be checking against setters, not getters

* Ensure args/params scores do not overwhelm Priority

* Remove possibility of NaNs
2017-06-29 17:43:55 -03:00
Finite Reality
cce572c600 Include names in command builder exceptions (#663) 2017-06-23 11:28:30 -03:00
RogueException
ba1982a3f9 Replaced DependencyMap with ServiceCollection and IServiceProvider (#625) 2017-05-04 12:52:26 -03:00
Christopher F
6000b15c4d C#7 TODOs 2017-04-23 15:13:31 -04:00
RogueException
1c6eebf875 Ensure command completes before cleaning up 2017-04-22 08:04:33 -03:00
RogueException
a6469e9021 Add support for void-returning commands 2017-04-07 05:48:33 -03:00
Joe4evr
f80687ef0e Fix ParameterInfo.Type sometimes being null 2017-02-01 04:06:24 +01:00
Joe4evr
c2599977a5 Add BeforeExecute/AfterExecute methods to ModuleBase 2017-01-30 03:14:12 +01:00
RogueException
c9a12cde10 Added default alias when GroupAttribute isn't provided 2016-12-29 20:57:07 -04:00
RogueException
2c075e186a Added support for custom ModuleBase command contexts. Added SocketCommandContext/RpcCommandContext. 2016-12-23 16:57:30 -04:00
RogueException
1965c0539a Added support for concrete Rest/Socket/RPC classes in command params 2016-12-23 16:57:29 -04:00
RogueException
ae3ada84c4 Renamed ModuleBuilder.AddAlias -> AddAliases 2016-12-18 18:21:24 -04:00
RogueException
8f87b2cc71 Added support for .NET Standard 1.1 and 1.2 2016-12-16 05:52:46 -04:00
FiniteReality
b4f8b0601f Fix #408
A.K.A. "FiniteReality is a twat"
2016-12-10 19:05:33 +00:00
FiniteReality
704b2b75f4 Fix changes after review 2016-12-03 23:51:20 +00:00
FiniteReality
254e874c99 Fix OverrideTypeReader
This commit also adds a TypeReaders property to CommandService, so
it is possible to see all of the registered TypeReaders. This makes
it possible for users to implement their own parsing instead of
using the built-in parsing.
2016-12-03 23:51:20 +00:00
FiniteReality
b7a5ee6542 Parameter preconditions and typereader overriding 2016-12-03 23:49:05 +00:00
FiniteReality
5cdda592c1 Add requested changes 2016-11-25 21:19:41 +00:00
FiniteReality
05fb81c617 Fix a bunch of issues with aliases 2016-11-20 20:20:23 +00:00
FiniteReality
fd5e237b41 Fix commands from being created with invalid aliases 2016-11-20 13:55:55 +00:00
RogueException
593ba46f1c Cleaned up command builders and async func names 2016-11-18 08:18:00 -04:00