feature: Send presence on Identify payload (#1688)
* Send presence on identify * Change CurrentUser presence
This commit is contained in:
@@ -12,6 +12,7 @@ using System.IO.Compression;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GameModel = Discord.API.Game;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
@@ -215,7 +216,7 @@ namespace Discord.API
|
||||
await _sentGatewayMessageEvent.InvokeAsync(opCode).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task SendIdentifyAsync(int largeThreshold = 100, int shardID = 0, int totalShards = 1, bool guildSubscriptions = true, GatewayIntents? gatewayIntents = null, RequestOptions options = null)
|
||||
public async Task SendIdentifyAsync(int largeThreshold = 100, int shardID = 0, int totalShards = 1, bool guildSubscriptions = true, GatewayIntents? gatewayIntents = null, (UserStatus, bool, long?, GameModel[])? presence = null, RequestOptions options = null)
|
||||
{
|
||||
options = RequestOptions.CreateOrClone(options);
|
||||
var props = new Dictionary<string, string>
|
||||
@@ -238,6 +239,17 @@ namespace Discord.API
|
||||
else
|
||||
msg.GuildSubscriptions = guildSubscriptions;
|
||||
|
||||
if (presence.HasValue)
|
||||
{
|
||||
msg.Presence = new StatusUpdateParams
|
||||
{
|
||||
Status = presence.Value.Item1,
|
||||
IsAFK = presence.Value.Item2,
|
||||
IdleSince = presence.Value.Item3,
|
||||
Activities = presence.Value.Item4
|
||||
};
|
||||
}
|
||||
|
||||
await SendGatewayAsync(GatewayOpCode.Identify, msg, options: options).ConfigureAwait(false);
|
||||
}
|
||||
public async Task SendResumeAsync(string sessionId, int lastSeq, RequestOptions options = null)
|
||||
@@ -256,7 +268,7 @@ namespace Discord.API
|
||||
options = RequestOptions.CreateOrClone(options);
|
||||
await SendGatewayAsync(GatewayOpCode.Heartbeat, lastSeq, options: options).ConfigureAwait(false);
|
||||
}
|
||||
public async Task SendStatusUpdateAsync(UserStatus status, bool isAFK, long? since, Game game, RequestOptions options = null)
|
||||
public async Task SendStatusUpdateAsync(UserStatus status, bool isAFK, long? since, GameModel[] game, RequestOptions options = null)
|
||||
{
|
||||
options = RequestOptions.CreateOrClone(options);
|
||||
var args = new StatusUpdateParams
|
||||
@@ -264,7 +276,7 @@ namespace Discord.API
|
||||
Status = status,
|
||||
IdleSince = since,
|
||||
IsAFK = isAFK,
|
||||
Game = game
|
||||
Activities = game
|
||||
};
|
||||
options.BucketId = GatewayBucket.Get(GatewayBucketType.PresenceUpdate).Id;
|
||||
await SendGatewayAsync(GatewayOpCode.StatusUpdate, args, options: options).ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user