feat: sessionId
This commit is contained in:
parent
5962c59684
commit
e8c2b967c3
@ -507,6 +507,14 @@ class Client extends BaseClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current session id of the shard
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
get sessionId() {
|
||||||
|
return this.ws.shards.first()?.sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for {@link Client#acceptInvite}.
|
* Options for {@link Client#acceptInvite}.
|
||||||
* @typedef {Object} AcceptInviteOptions
|
* @typedef {Object} AcceptInviteOptions
|
||||||
@ -539,7 +547,7 @@ class Client extends BaseClient {
|
|||||||
const data = await this.api.invites(code).post({
|
const data = await this.api.invites(code).post({
|
||||||
DiscordContext: { location: 'Markdown Link' },
|
DiscordContext: { location: 'Markdown Link' },
|
||||||
data: {
|
data: {
|
||||||
session_id: this.ws.shards.first()?.sessionId,
|
session_id: this.sessionId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Joined`);
|
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Joined`);
|
||||||
|
@ -1025,7 +1025,7 @@ class Message extends Base {
|
|||||||
channel_id: this.channelId,
|
channel_id: this.channelId,
|
||||||
message_id: this.id,
|
message_id: this.id,
|
||||||
application_id: this.applicationId ?? this.author.id,
|
application_id: this.applicationId ?? this.author.id,
|
||||||
session_id: this.client.ws.shards.first()?.sessionId,
|
session_id: this.client.sessionId,
|
||||||
message_flags: this.flags.bitfield,
|
message_flags: this.flags.bitfield,
|
||||||
data: {
|
data: {
|
||||||
component_type: MessageComponentTypes.BUTTON,
|
component_type: MessageComponentTypes.BUTTON,
|
||||||
@ -1124,7 +1124,7 @@ class Message extends Base {
|
|||||||
channel_id: this.channelId,
|
channel_id: this.channelId,
|
||||||
message_id: this.id,
|
message_id: this.id,
|
||||||
application_id: this.applicationId ?? this.author.id,
|
application_id: this.applicationId ?? this.author.id,
|
||||||
session_id: this.client.ws.shards.first()?.sessionId,
|
session_id: this.client.sessionId,
|
||||||
message_flags: this.flags.bitfield,
|
message_flags: this.flags.bitfield,
|
||||||
data: {
|
data: {
|
||||||
component_type: MessageComponentTypes[selectMenu.type],
|
component_type: MessageComponentTypes[selectMenu.type],
|
||||||
|
@ -205,7 +205,7 @@ class MessagePayload {
|
|||||||
this.options.activity.type
|
this.options.activity.type
|
||||||
) {
|
) {
|
||||||
const type = ActivityFlags.resolve(this.options.activity.type);
|
const type = ActivityFlags.resolve(this.options.activity.type);
|
||||||
const sessionId = this.target.client.ws.shards.first()?.sessionId;
|
const sessionId = this.target.client.sessionId;
|
||||||
const partyId = this.options.activity.partyId;
|
const partyId = this.options.activity.partyId;
|
||||||
activity = {
|
activity = {
|
||||||
type,
|
type,
|
||||||
|
@ -132,7 +132,7 @@ class Modal {
|
|||||||
channel_id: this.channelId,
|
channel_id: this.channelId,
|
||||||
data: dataFinal,
|
data: dataFinal,
|
||||||
nonce,
|
nonce,
|
||||||
session_id: this.client.ws.shards.first()?.sessionId,
|
session_id: this.client.sessionId,
|
||||||
};
|
};
|
||||||
this.client.api.interactions.post({
|
this.client.api.interactions.post({
|
||||||
data: postData,
|
data: postData,
|
||||||
|
@ -703,7 +703,7 @@ function createPostData(
|
|||||||
application_id: applicationId,
|
application_id: applicationId,
|
||||||
guild_id: guildId,
|
guild_id: guildId,
|
||||||
channel_id: channelId,
|
channel_id: channelId,
|
||||||
session_id: client.ws.shards.first()?.sessionId,
|
session_id: client.sessionId,
|
||||||
data: {
|
data: {
|
||||||
version: commandVersion,
|
version: commandVersion,
|
||||||
id: commandId,
|
id: commandId,
|
||||||
|
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@ -791,6 +791,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
|||||||
public presences: PresenceManager;
|
public presences: PresenceManager;
|
||||||
public billing: BillingManager;
|
public billing: BillingManager;
|
||||||
public settings: ClientUserSettingManager;
|
public settings: ClientUserSettingManager;
|
||||||
|
public readonly sessionId: If<Ready, string, undefined>;
|
||||||
public destroy(): void;
|
public destroy(): void;
|
||||||
public fetchGuildPreview(guild: GuildResolvable): Promise<GuildPreview>;
|
public fetchGuildPreview(guild: GuildResolvable): Promise<GuildPreview>;
|
||||||
public fetchInvite(invite: InviteResolvable, options?: ClientFetchInviteOptions): Promise<Invite>;
|
public fetchInvite(invite: InviteResolvable, options?: ClientFetchInviteOptions): Promise<Invite>;
|
||||||
|
Loading…
Reference in New Issue
Block a user