Browse Source

fix: ensure add/del rxn ends up in the same bucket

pull/1108/head
Christopher F 7 years ago
parent
commit
9ca78e06bf
2 changed files with 7 additions and 3 deletions
  1. +6
    -2
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  2. +1
    -1
      src/Discord.Net.Rest/Net/Queue/RequestQueue.cs

+ 6
- 2
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -576,6 +576,7 @@ namespace Discord.API
var ids = new BucketIds(channelId: channelId);
return await SendJsonAsync<Message>("PATCH", () => $"channels/{channelId}/messages/{messageId}", args, ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false);
}

public async Task AddReactionAsync(ulong channelId, ulong messageId, string emoji, RequestOptions options = null)
{
Preconditions.NotEqual(channelId, 0, nameof(channelId));
@@ -587,7 +588,9 @@ namespace Discord.API

var ids = new BucketIds(channelId: channelId);

await SendAsync("PUT", () => $"channels/{channelId}/messages/{messageId}/reactions/{emoji}/@me", ids, options: options).ConfigureAwait(false);
// @me is non-const to fool the ratelimiter, otherwise it will put add/remove in separate buckets
var me = "@me";
await SendAsync("PUT", () => $"channels/{channelId}/messages/{messageId}/reactions/{emoji}/{me}", ids, options: options).ConfigureAwait(false);
}
public async Task RemoveReactionAsync(ulong channelId, ulong messageId, ulong userId, string emoji, RequestOptions options = null)
{
@@ -600,7 +603,8 @@ namespace Discord.API

var ids = new BucketIds(channelId: channelId);

await SendAsync("DELETE", () => $"channels/{channelId}/messages/{messageId}/reactions/{emoji}/{userId}", ids, options: options).ConfigureAwait(false);
var user = CurrentUserId.HasValue ? (userId == CurrentUserId.Value ? "@me" : userId.ToString()) : userId.ToString();
await SendAsync("DELETE", () => $"channels/{channelId}/messages/{messageId}/reactions/{emoji}/{user}", ids, options: options).ConfigureAwait(false);
}
public async Task RemoveAllReactionsAsync(ulong channelId, ulong messageId, RequestOptions options = null)
{


+ 1
- 1
src/Discord.Net.Rest/Net/Queue/RequestQueue.cs View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Concurrent;
#if DEBUG_LIMITS
using System.Diagnostics;


Loading…
Cancel
Save