Browse Source

Inlined variable declarations (#185)

pull/1923/head
Simon Hjorthøj GitHub 3 years ago
parent
commit
dba39621cd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 13 deletions
  1. +1
    -2
      src/Discord.Net.Commands/Extensions/MessageExtensions.cs
  2. +1
    -2
      src/Discord.Net.Webhook/DiscordWebhookClient.cs
  3. +3
    -9
      test/Discord.Net.Tests.Unit/MentionUtilsTests.cs

+ 1
- 2
src/Discord.Net.Commands/Extensions/MessageExtensions.cs View File

@@ -51,8 +51,7 @@ namespace Discord.Commands
if (endPos == -1) return false;
if (text.Length < endPos + 2 || text[endPos + 1] != ' ') return false; //Must end in "> "

ulong userId;
if (!MentionUtils.TryParseUser(text.Substring(0, endPos + 1), out userId)) return false;
if (!MentionUtils.TryParseUser(text.Substring(0, endPos + 1), out ulong userId)) return false;
if (userId == user.Id)
{
argPos = endPos + 2;


+ 1
- 2
src/Discord.Net.Webhook/DiscordWebhookClient.cs View File

@@ -60,8 +60,7 @@ namespace Discord.Webhook
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="webhookUrl"/> is null or whitespace.</exception>
public DiscordWebhookClient(string webhookUrl, DiscordRestConfig config) : this(config)
{
string token;
ParseWebhookUrl(webhookUrl, out _webhookId, out token);
ParseWebhookUrl(webhookUrl, out _webhookId, out string token);
ApiClient.LoginAsync(TokenType.Webhook, token).GetAwaiter().GetResult();
Webhook = WebhookClientHelper.GetWebhookAsync(this, _webhookId).GetAwaiter().GetResult();
}


+ 3
- 9
test/Discord.Net.Tests.Unit/MentionUtilsTests.cs View File

@@ -47,9 +47,7 @@ namespace Discord
var parsed = MentionUtils.ParseUser(user);
Assert.Equal(id, parsed);

// also check tryparse
ulong result;
Assert.True(MentionUtils.TryParseUser(user, out result));
Assert.True(MentionUtils.TryParseUser(user, out ulong result));
Assert.Equal(id, result);
}
[Theory]
@@ -75,9 +73,7 @@ namespace Discord
var parsed = MentionUtils.ParseChannel(channel);
Assert.Equal(id, parsed);

// also check tryparse
ulong result;
Assert.True(MentionUtils.TryParseChannel(channel, out result));
Assert.True(MentionUtils.TryParseChannel(channel, out ulong result));
Assert.Equal(id, result);
}
[Theory]
@@ -103,9 +99,7 @@ namespace Discord
var parsed = MentionUtils.ParseRole(role);
Assert.Equal(id, parsed);

// also check tryparse
ulong result;
Assert.True(MentionUtils.TryParseRole(role, out result));
Assert.True(MentionUtils.TryParseRole(role, out ulong result));
Assert.Equal(id, result);
}
[Theory]


Loading…
Cancel
Save