Browse Source

use only stringbuilder for args instead of string interpolation

pull/1377/head
Chris Johnston 6 years ago
parent
commit
d8cc1072f1
1 changed files with 15 additions and 5 deletions
  1. +15
    -5
      src/Discord.Net.Rest/DiscordRestApiClient.cs

+ 15
- 5
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -1321,15 +1321,25 @@ namespace Discord.API
var ids = new BucketIds(guildId: guildId);
Expression<Func<string>> endpoint;

var query = new StringBuilder();
var queryArgs = new StringBuilder();
if (args.BeforeEntryId.IsSpecified)
query.Append($"&before={args.BeforeEntryId.Value}");
{
queryArgs.Append("&before=")
.Append(args.BeforeEntryId);
}
if (args.UserId.IsSpecified)
query.Append($"&user_id={args.UserId.Value}");
{
queryArgs.Append("&user_id=")
.Append(args.UserId.Value);
}
if (args.ActionType.IsSpecified)
query.Append($"&action_type={args.ActionType.Value}");
{
queryArgs.Append("&action_type=")
.Append(args.ActionType.Value);
}

endpoint = () => $"guilds/{guildId}/audit-logs?limit={limit}{query.ToString()}";
// still use string interp for the query w/o params, as this is necessary for CreateBucketId
endpoint = () => $"guilds/{guildId}/audit-logs?limit={limit}{queryArgs.ToString()}";
return await SendAsync<AuditLog>("GET", endpoint, ids, options: options).ConfigureAwait(false);
}



Loading…
Cancel
Save