Skip to content

Commit

Permalink
Inlined variable declarations (discord-net#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
killerfrienddk authored Sep 24, 2021
1 parent d897ba1 commit dba3962
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/Discord.Net.Commands/Extensions/MessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public static bool HasMentionPrefix(this IUserMessage msg, IUser user, ref int a
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;
Expand Down
3 changes: 1 addition & 2 deletions src/Discord.Net.Webhook/DiscordWebhookClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public DiscordWebhookClient(IWebhook webhook, DiscordRestConfig config)
/// <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();
}
Expand Down
12 changes: 3 additions & 9 deletions test/Discord.Net.Tests.Unit/MentionUtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public void ParseUser_Pass(string user, ulong id)
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]
Expand All @@ -75,9 +73,7 @@ public void ParseChannel_Pass(string channel, ulong id)
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]
Expand All @@ -103,9 +99,7 @@ public void ParseRole_Pass(string role, ulong id)
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]
Expand Down

0 comments on commit dba3962

Please sign in to comment.