feat(DMChannel): Message request
This commit is contained in:
parent
31e0de6a05
commit
91ae4195a6
@ -61,6 +61,51 @@ class DMChannel extends Channel {
|
|||||||
} else {
|
} else {
|
||||||
this.lastPinTimestamp ??= null;
|
this.lastPinTimestamp ??= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('is_message_request' in data) {
|
||||||
|
/**
|
||||||
|
* Whether the channel is a message request
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.messageRequest = data.is_message_request;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('is_message_request_timestamp' in data) {
|
||||||
|
/**
|
||||||
|
* The timestamp when the message request was created
|
||||||
|
* @type {?number}
|
||||||
|
*/
|
||||||
|
this.messageRequestTimestamp = new Date(data.is_message_request_timestamp).getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept this DMChannel.
|
||||||
|
* @returns {Promise<DMChannel>}
|
||||||
|
*/
|
||||||
|
async acceptMessageRequest() {
|
||||||
|
if (!this.messageRequest) {
|
||||||
|
throw new Error('NOT_MESSAGE_REQUEST', 'This channel is not a message request');
|
||||||
|
}
|
||||||
|
const c = await this.client.api.channels[this.id].recipients['@me'].put({
|
||||||
|
data: {
|
||||||
|
consent_status: 2,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.messageRequest = false;
|
||||||
|
return this.client.channels._add(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel this DMChannel.
|
||||||
|
* @returns {Promise<DMChannel>}
|
||||||
|
*/
|
||||||
|
async cancelMessageRequest() {
|
||||||
|
if (!this.messageRequest) {
|
||||||
|
throw new Error('NOT_MESSAGE_REQUEST', 'This channel is not a message request');
|
||||||
|
}
|
||||||
|
await this.client.api.channels[this.id].recipients['@me'].delete();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
4
typings/index.d.ts
vendored
4
typings/index.d.ts
vendored
@ -2384,6 +2384,10 @@ export class PartialGroupDMChannel extends TextBasedChannelMixin(Channel, [
|
|||||||
public owner: User | null;
|
public owner: User | null;
|
||||||
public ownerId: Snowflake | null;
|
public ownerId: Snowflake | null;
|
||||||
public flags: null;
|
public flags: null;
|
||||||
|
public messageRequest: boolean | undefined;
|
||||||
|
public messageRequestTimestamp: Date | undefined;
|
||||||
|
public acceptMessageRequest(): Promise<this>;
|
||||||
|
public cancelMessageRequest(): Promise<this>;
|
||||||
public iconURL(options?: StaticImageURLOptions): string | null;
|
public iconURL(options?: StaticImageURLOptions): string | null;
|
||||||
public addMember(user: User): Promise<PartialGroupDMChannel>;
|
public addMember(user: User): Promise<PartialGroupDMChannel>;
|
||||||
public removeMember(user: User): Promise<PartialGroupDMChannel>;
|
public removeMember(user: User): Promise<PartialGroupDMChannel>;
|
||||||
|
Loading…
Reference in New Issue
Block a user