mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
feat: User.openDM()
This commit is contained in:
parent
8f370d4c59
commit
3fcbe6ac87
@ -685,6 +685,12 @@ export class DMChannel extends BaseChannel implements Model {
|
||||
|
||||
return new DMChannel(this.session, channel);
|
||||
}
|
||||
|
||||
async open(userId: Snowflake): Promise<DMChannel> {
|
||||
const channel = await this.session.rest.post<DiscordChannel>(USER_DM(), { recipient_id: userId});
|
||||
|
||||
return new DMChannel(this.session, channel);
|
||||
}
|
||||
}
|
||||
|
||||
export interface DMChannel extends Omit<TextChannel, 'type'>, Omit<BaseChannel, 'type'> {}
|
||||
|
@ -5,6 +5,7 @@ import type { DiscordUser, PremiumTypes, UserFlags } from '@biscuitland/api-type
|
||||
import type { ImageFormat, ImageSize } from '../utils/util';
|
||||
import { USER, USER_AVATAR, USER_DEFAULT_AVATAR } from '@biscuitland/api-types';
|
||||
import { Util } from '../utils/util';
|
||||
import { DMChannel } from './channels';
|
||||
|
||||
export type AvatarOptions = {
|
||||
format?: ImageFormat;
|
||||
@ -113,6 +114,10 @@ export class User implements Model {
|
||||
return Util.formatImageURL(url, options.size ?? 128, options.format);
|
||||
}
|
||||
|
||||
openDM(): Promise<DMChannel> {
|
||||
return DMChannel.prototype.open.call({ session: this.session }, this.id);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<@${this.id}>`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user