Skip to content

Commit

Permalink
Conditional-expression-simplification (discord-net#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
killerfrienddk authored Sep 24, 2021
1 parent 0b47c71 commit a8ffa5d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ public ComponentBuilder WithButton(ButtonBuilder button, int row = 0)

if (_actionRows == null)
{
_actionRows = new List<ActionRowBuilder>();
_actionRows.Add(new ActionRowBuilder().AddComponent(builtButton));
_actionRows = new List<ActionRowBuilder>
{
new ActionRowBuilder().AddComponent(builtButton)
};
}
else
{
Expand Down
11 changes: 6 additions & 5 deletions src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ internal class CreateStickerParams

public IReadOnlyDictionary<string, object> ToDictionary()
{
var d = new Dictionary<string, object>();

d["name"] = $"{Name}";
d["description"] = Description;
d["tags"] = Tags;
var d = new Dictionary<string, object>
{
["name"] = $"{Name}",
["description"] = Description,
["tags"] = Tags
};

string contentType = "image/png";

Expand Down
7 changes: 4 additions & 3 deletions src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ public IReadOnlyDictionary<string, object> ToDictionary()
d["file"] = File.Value;
}

var payload = new Dictionary<string, object>();

payload["content"] = Content;
var payload = new Dictionary<string, object>
{
["content"] = Content
};

if (IsTTS.IsSpecified)
payload["tts"] = IsTTS.Value.ToString();
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Rest/Extensions/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static RoleTags ToEntity(this API.RoleTags model)
return new RoleTags(
model.BotId.IsSpecified ? model.BotId.Value : null,
model.IntegrationId.IsSpecified ? model.IntegrationId.Value : null,
model.IsPremiumSubscriber.IsSpecified ? true : false);
model.IsPremiumSubscriber.IsSpecified);
}
public static API.Embed ToModel(this Embed entity)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private void UpdateRateLimit(int id, IRequest request, RateLimitInfo info, bool
Debug.WriteLine($"[{id}] Retry-After: {info.RetryAfter.Value} ({info.RetryAfter.Value} ms)");
#endif
}
else if (info.ResetAfter.HasValue && (request.Options.UseSystemClock.HasValue ? !request.Options.UseSystemClock.Value : false))
else if (info.ResetAfter.HasValue && (request.Options.UseSystemClock.HasValue && !request.Options.UseSystemClock.Value))
{
resetTick = DateTimeOffset.UtcNow.Add(info.ResetAfter.Value);
#if DEBUG_LIMITS
Expand Down
2 changes: 1 addition & 1 deletion src/Discord.Net.WebSocket/DiscordSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty

SocketStageChannel before = type == "STAGE_INSTANCE_UPDATE" ? stageChannel.Clone() : null;

stageChannel.Update(data, type == "STAGE_INSTANCE_CREATE" ? true : type == "STAGE_INSTANCE_DELETE" ? false : false);
stageChannel.Update(data, type == "STAGE_INSTANCE_CREATE");

switch (type)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ public override bool Equals(object obj)
stickerModel.Type == this.Type &&
stickerModel.SortValue == this.SortOrder &&
stickerModel.Available == this.Available &&
(stickerModel.Tags.IsSpecified ?
stickerModel.Tags.Value == string.Join(", ", this.Tags) :
true);
(!stickerModel.Tags.IsSpecified || stickerModel.Tags.Value == string.Join(", ", this.Tags));
}
else
return base.Equals(obj);
Expand Down

0 comments on commit a8ffa5d

Please sign in to comment.