Browse Source

Merge branch 'dev' into docs/pre-release

pull/1161/head
Still Hsu 7 years ago
parent
commit
18c0146582
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
3 changed files with 12 additions and 4 deletions
  1. +5
    -2
      src/Discord.Net.Commands/CommandService.cs
  2. +1
    -1
      src/Discord.Net.Core/Discord.Net.Core.csproj
  3. +6
    -1
      src/Discord.Net.Rest/ClientHelper.cs

+ 5
- 2
src/Discord.Net.Commands/CommandService.cs View File

@@ -414,7 +414,7 @@ namespace Discord.Commands
/// <param name="argPos">The position of which the command starts at.</param> /// <param name="argPos">The position of which the command starts at.</param>
/// <returns>The result containing the matching commands.</returns> /// <returns>The result containing the matching commands.</returns>
public SearchResult Search(ICommandContext context, int argPos) public SearchResult Search(ICommandContext context, int argPos)
=> Search(context, context.Message.Content.Substring(argPos));
=> Search(context.Message.Content.Substring(argPos));
/// <summary> /// <summary>
/// Searches for the command. /// Searches for the command.
/// </summary> /// </summary>
@@ -422,6 +422,8 @@ namespace Discord.Commands
/// <param name="input">The command string.</param> /// <param name="input">The command string.</param>
/// <returns>The result containing the matching commands.</returns> /// <returns>The result containing the matching commands.</returns>
public SearchResult Search(ICommandContext context, string input) public SearchResult Search(ICommandContext context, string input)
=> Search(input);
public SearchResult Search(string input)
{ {
string searchInput = _caseSensitive ? input : input.ToLowerInvariant(); string searchInput = _caseSensitive ? input : input.ToLowerInvariant();
var matches = _map.GetCommands(searchInput).OrderByDescending(x => x.Command.Priority).ToImmutableArray(); var matches = _map.GetCommands(searchInput).OrderByDescending(x => x.Command.Priority).ToImmutableArray();
@@ -453,7 +455,8 @@ namespace Discord.Commands
public async Task<IResult> ExecuteAsync(ICommandContext context, string input, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception) public async Task<IResult> ExecuteAsync(ICommandContext context, string input, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception)
{ {
services = services ?? EmptyServiceProvider.Instance; services = services ?? EmptyServiceProvider.Instance;
var searchResult = Search(context, input);

var searchResult = Search(input);
if (!searchResult.IsSuccess) if (!searchResult.IsSuccess)
return searchResult; return searchResult;




+ 1
- 1
src/Discord.Net.Core/Discord.Net.Core.csproj View File

@@ -9,7 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.Collections.Immutable" Version="1.4.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
<PackageReference Include="System.Interactive.Async" Version="3.1.1" /> <PackageReference Include="System.Interactive.Async" Version="3.1.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

+ 6
- 1
src/Discord.Net.Rest/ClientHelper.cs View File

@@ -144,9 +144,14 @@ namespace Discord.Rest
public static async Task<RestGuildUser> GetGuildUserAsync(BaseDiscordClient client, public static async Task<RestGuildUser> GetGuildUserAsync(BaseDiscordClient client,
ulong guildId, ulong id, RequestOptions options) ulong guildId, ulong id, RequestOptions options)
{ {
var guild = await GetGuildAsync(client, guildId, options).ConfigureAwait(false);
if (guild == null)
return null;

var model = await client.ApiClient.GetGuildMemberAsync(guildId, id, options).ConfigureAwait(false); var model = await client.ApiClient.GetGuildMemberAsync(guildId, id, options).ConfigureAwait(false);
if (model != null) if (model != null)
return RestGuildUser.Create(client, new RestGuild(client, guildId), model);
return RestGuildUser.Create(client, guild, model);

return null; return null;
} }




Loading…
Cancel
Save