-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Sticker.ts
58 lines (50 loc) · 1.94 KB
/
Sticker.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type {
APISticker,
RESTPatchAPIGuildStickerJSONBody,
RESTPostAPIGuildStickerFormDataBody,
} from 'discord-api-types/v10';
import type { UsingClient } from '..';
import type { Attachment } from '../builders';
import type { MethodContext, ObjectToLower } from '../common';
import { User } from './User';
import { DiscordBase } from './extra/DiscordBase';
export interface Sticker extends DiscordBase, ObjectToLower<Omit<APISticker, 'user'>> {}
export class Sticker extends DiscordBase {
user?: User;
constructor(client: UsingClient, data: APISticker) {
super(client, data);
if (data.user) {
this.user = new User(this.client, data.user);
}
}
guild(force = false) {
if (!this.guildId) return;
return this.client.guilds.fetch(this.id, force);
}
edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) {
if (!this.guildId) return;
return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason);
}
fetch(force = false) {
if (!this.guildId) return;
return this.client.guilds.stickers.fetch(this.guildId, this.id, force);
}
delete(reason?: string) {
if (!this.guildId) return;
return this.client.guilds.stickers.delete(this.guildId, this.id, reason);
}
static methods({ client, guildId }: MethodContext<{ guildId: string }>) {
return {
list: () => client.guilds.stickers.list(guildId),
create: (payload: CreateStickerBodyRequest, reason?: string) =>
client.guilds.stickers.create(guildId, payload, reason),
edit: (stickerId: string, body: RESTPatchAPIGuildStickerJSONBody, reason?: string) =>
client.guilds.stickers.edit(guildId, stickerId, body, reason),
fetch: (stickerId: string, force = false) => client.guilds.stickers.fetch(guildId, stickerId, force),
delete: (stickerId: string, reason?: string) => client.guilds.stickers.delete(guildId, stickerId, reason),
};
}
}
export interface CreateStickerBodyRequest extends Omit<RESTPostAPIGuildStickerFormDataBody, 'file'> {
file: Attachment;
}