Commit Graph

571 Commits

Author SHA1 Message Date
Christopher F
97397f3617 Apply consistency to attributes in the commands extension (#928)
* Apply consistency to attributes in the commands extension

This resolves #527.

Not sure if I missed any, putting this up for review.

* Allow preconditions to be used multiple times (for use with groups)
2018-01-08 12:56:31 -05:00
ObsidianMinor
5bbd9bba82 Renamed existing Flatten method to FlattenAsync and added new Flatten method. Also fixed ClientHelper using incorrect guild batch count. (#744) 2018-01-06 22:43:11 -05:00
vim2meta
5f46aef3a7 Ability to ignore unused parameters instead of failing the command. (#915)
* Addition of FailOnTooManyArgs

* Correct name & only pass in bool
2018-01-05 15:02:27 -05:00
Christopher F
e5dfb6c3e5 Fix null channel being passed in RequirePermission preconditions (#886)
* Fix null channel being passed in RequirePermission preconditions

* c#7 pattern matching
2017-11-21 16:33:46 -05:00
Christopher F
8d533930fa Move CommandExecuted invoking up a scope for generic Task commands
Resovles #870
2017-11-10 15:26:58 -05:00
Christopher F
14fbe40cbc Add Async suffix to command-related Tasks (#804)
commit b7fb44a94fb1e75f696f281d6b201eba3f48e864
Author: Hsu Still <341464@gmail.com>
Date:   Sat Sep 2 14:34:18 2017 +0800

    Fix more async naming violation

commit e6912e2d020c69325826dbfa62c07cd1ef2cc45f
Author: Hsu Still <341464@gmail.com>
Date:   Sat Sep 2 14:23:04 2017 +0800

    Fix incorrect null xmldocs string

commit da8d23222d207853375c3512232d1d7fd3629cad
Author: Hsu Still <341464@gmail.com>
Date:   Sat Sep 2 14:17:12 2017 +0800

    Fix CheckPreconditionsAsync

commit 992407407a42fec9087c9ed18e0bf5de30dff82c
Author: Hsu Still <341464@gmail.com>
Date:   Sat Sep 2 14:07:12 2017 +0800

    Add Async suffix to abstract Task methods
2017-10-09 19:45:12 -04:00
Vollrat
71e8b88514 Improve upon Property Summaries in CommandServiceConfig (#839)
* Improve Boolean Property Summaries

Having the `CaseSensitiveCommands` property summary asking a question whenever Intellisense is invoked seems a bit nonessential instead of *properly* explaining what exactly it does. It would be better if instead, it stated it's use to be more comprehensible to the reader.

### Changes

- Edits the summaries of `CaseSensitiveCommands` and `ThrowOnError` to follow a more methodical convention for boolean property summaries (`Determines whether X ...` rather than `Should X be ... ?`).

This is just a small change to improve upon the current documentation, so it shouldn't conflict with anything.

* "DefaultRunMode should also be "Gets or sets blah blah blah" to be consistent."
2017-10-03 20:04:38 -04:00
Christopher F
347c5a0d39 Disable obsolete warnings in files that reference TokenType.User 2017-09-29 17:37:07 -04:00
Christopher F
608bc359ee Removed IChannel#Nsfw, added to ITextChannel 2017-08-29 17:26:36 -04:00
Christopher F
e991715bac Added CommandService.CommandExecuted (#747) 2017-08-29 16:50:32 -04:00
Izumemori
9c81ab9fe4 changed NameAttribute to work for parameter (#765) 2017-08-29 16:45:30 -04:00
Alex Gravely
cb0ff7817d Add NullableTypeReader (#785)
* Add NullableTypeReader.

Primitives now also load a NullableTypeReader<T> and any value types that get a typereader added will also have a NullableTypeReader<T> added for it.

* Remove unnecessary null check.

* Added docstrings.
2017-08-29 16:38:11 -04:00
RogueException
dfcb4b39fb Allow duplicate RequireBotPermissionAttribute 2017-08-17 02:41:42 -03: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
Finite Reality
7597cf5baa Fix CalculateScore throwing on missing parameters (#727)
* Fix CalculateScore throwing on missing parameters

* Bump to version 1.0.1
2017-07-05 20:09:38 -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
Christopher F
3b8434cdc4 Merge pull request #715 from Joe4evr/patch-2
PreconditionGroup quick fix
2017-06-28 13:02:58 -04:00
Joe4evr
cc390f03de Fix the off-chance that someone has a property without a getter 2017-06-24 02:56:57 +02:00
Joe4evr
34917a35de In my defense, it was 2:40 AM 2017-06-24 02:50:30 +02:00
Joe4evr
444868b22d Fix attempting to inject into static properties 2017-06-24 02:39:15 +02:00
Joe4evr
36ed2b49f0 PreconditionGroup quick fix
It didn't make much sense
2017-06-23 20:46:59 +02:00
Finite Reality
cce572c600 Include names in command builder exceptions (#663) 2017-06-23 11:28:30 -03:00
Joe4evr
4a9c8168a9 Add grouping of preconditions to allow for flexible precondition logic. (#672)
* Add grouping of preconditions to allow for flexible precondition logic.

* Fix checking Module Preconditions twice (and none of the command's own)

* Fix command preconditions group 0 looping over every other precondition anyway #whoopsies

* Use custom message when a non-zero Precondition Group fails.

* Fix doc comment rendering.

* Refactor loops into local function

* Considering a new result type

* Switch to IReadOnlyCollection<T> and fix compiler errors

* Revert PreconditionResult -> IResult in return types - Change PreconditionResult to a class that PreconditionGroupResult inherits.

* Feedback on property name.

* Change grouping type int -> string

* Explicitly use an ordinal StringComparer

* Full stops on error messages

* Remove some sillyness.

* Remove unneeded using.
2017-06-23 11:28:22 -03:00
FiniteReality
0550006d56 Change wording of permission preconditions
Also fix an issue where RequireBotPermission may throw if used in a
non-guild channel which required guild permissions.
2017-06-17 15:10:35 +01:00
RogueException
285a0e5817 Updated deps, cleaned csprojs 2017-05-09 20:51:00 -03:00
FiniteReality
1e888cde24 Fix CheckPreconditions giving empty service provider
Parameter preconditions were always getting the empty service provider,
even when a custom one was provided in ExecuteAsync, which means that
preconditions which use services cannot work properly.
2017-05-08 22:15:47 +01:00
FiniteReality
00895b1227 Remove CommandService.BuildServiceCollection
💥
2017-05-06 18:25:44 +01:00
Finite Reality
112a434424 Allow for case-insensitive HasStringPrefix (#644)
This was 👍'd in the dev chat, I forgot to make a PR for it (whoops!)
2017-05-06 02:39:46 -03:00
RogueException
870dc50a68 Fixed RequireNsfwAttribute definition 2017-05-04 13:15:51 -03:00
RogueException
ba1982a3f9 Replaced DependencyMap with ServiceCollection and IServiceProvider (#625) 2017-05-04 12:52:26 -03:00
Christopher F
7f1fc286cf Add IChannel.Nsfw, RequireNsfw precondition (#633)
* Add IChannel.Nsfw, RequireNsfw precondition

* Refactored IChannel.Nsfw to IsNsfw, removed NsfwUtils

Per pull-request feedback

* proper nsfw channel check
2017-05-04 12:49:32 -03:00
Bond-009
cb4f6e37f6 Overloaded AddModuleAsync with Type (#581)
* Overloaded AddModuleAsync with Type

* Overloaded RemoveModuleAsync with Type

* Use expression-bodied method for consistency
2017-04-29 04:42:47 -03:00
Confruggy
3365bbb043 Fixes ChannelTypeReader (#630) 2017-04-28 11:49:59 -03:00
Confruggy
4ca273dd4a Fixes RoleTypeReader (#631) 2017-04-28 11:49:50 -03:00
RogueException
f8b9acc4a1 Use implicit package references (#626) 2017-04-26 10:03:23 -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
aca8def0cb ModuleBase should map to ICommandContext 2017-04-08 18:38:58 -03:00
RogueException
a6469e9021 Add support for void-returning commands 2017-04-07 05:48:33 -03:00
RogueException
bceb72dd92 Typo 2017-04-06 20:57:46 -03:00
RogueException
17ba8fe4d0 Better handle the primary alias. 2017-04-06 20:50:48 -03:00
RogueException
33cd1a6c9f Scan base types during DI injection 2017-04-06 20:29:42 -03:00
RogueException
14f0535a43 Improved typereader not found message 2017-04-05 23:53:20 -03:00
RogueException
b5d817f171 Cleaned up csprojs, added support for tag builds. 2017-04-01 11:11:09 -03:00
Christopher F
2b4a1249f4 Restrict DependencyMap#Get to reference types
It's impossible to add non-reference types to the map, so why allow pulling them out of it.
2017-03-25 17:08:45 -04:00
RogueException
bbd45a6f4b Fixed CommandException 2017-03-25 11:19:31 -03:00