mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
fix: support AttachmentBuilder when creating a sticker
This commit is contained in:
parent
00640bfda7
commit
482de42b28
@ -1,58 +1,58 @@
|
|||||||
import type {
|
import type {
|
||||||
APISticker,
|
APISticker,
|
||||||
RESTPatchAPIGuildStickerJSONBody,
|
RESTPatchAPIGuildStickerJSONBody,
|
||||||
RESTPostAPIGuildStickerFormDataBody,
|
RESTPostAPIGuildStickerFormDataBody,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
import type { UsingClient } from '..';
|
import type { RawFile, UsingClient } from '..';
|
||||||
import type { Attachment } from '../builders';
|
import type { Attachment, AttachmentBuilder } from '../builders';
|
||||||
import type { MethodContext, ObjectToLower } from '../common';
|
import type { MethodContext, ObjectToLower } from '../common';
|
||||||
import { User } from './User';
|
import { User } from './User';
|
||||||
import { DiscordBase } from './extra/DiscordBase';
|
import { DiscordBase } from './extra/DiscordBase';
|
||||||
|
|
||||||
export interface Sticker extends DiscordBase, ObjectToLower<Omit<APISticker, 'user'>> {}
|
export interface Sticker extends DiscordBase, ObjectToLower<Omit<APISticker, 'user'>> {}
|
||||||
|
|
||||||
export class Sticker extends DiscordBase {
|
export class Sticker extends DiscordBase {
|
||||||
user?: User;
|
user?: User;
|
||||||
constructor(client: UsingClient, data: APISticker) {
|
constructor(client: UsingClient, data: APISticker) {
|
||||||
super(client, data);
|
super(client, data);
|
||||||
if (data.user) {
|
if (data.user) {
|
||||||
this.user = new User(this.client, data.user);
|
this.user = new User(this.client, data.user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guild(force = false) {
|
guild(force = false) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.fetch(this.id, force);
|
return this.client.guilds.fetch(this.id, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) {
|
edit(body: RESTPatchAPIGuildStickerJSONBody, reason?: string) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason);
|
return this.client.guilds.stickers.edit(this.guildId, this.id, body, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(force = false) {
|
fetch(force = false) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.stickers.fetch(this.guildId, this.id, force);
|
return this.client.guilds.stickers.fetch(this.guildId, this.id, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(reason?: string) {
|
delete(reason?: string) {
|
||||||
if (!this.guildId) return;
|
if (!this.guildId) return;
|
||||||
return this.client.guilds.stickers.delete(this.guildId, this.id, reason);
|
return this.client.guilds.stickers.delete(this.guildId, this.id, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
static methods({ client, guildId }: MethodContext<{ guildId: string }>) {
|
static methods({ client, guildId }: MethodContext<{ guildId: string }>) {
|
||||||
return {
|
return {
|
||||||
list: () => client.guilds.stickers.list(guildId),
|
list: () => client.guilds.stickers.list(guildId),
|
||||||
create: (payload: CreateStickerBodyRequest, reason?: string) =>
|
create: (payload: CreateStickerBodyRequest, reason?: string) =>
|
||||||
client.guilds.stickers.create(guildId, payload, reason),
|
client.guilds.stickers.create(guildId, payload, reason),
|
||||||
edit: (stickerId: string, body: RESTPatchAPIGuildStickerJSONBody, reason?: string) =>
|
edit: (stickerId: string, body: RESTPatchAPIGuildStickerJSONBody, reason?: string) =>
|
||||||
client.guilds.stickers.edit(guildId, stickerId, body, reason),
|
client.guilds.stickers.edit(guildId, stickerId, body, reason),
|
||||||
fetch: (stickerId: string, force = false) => client.guilds.stickers.fetch(guildId, stickerId, force),
|
fetch: (stickerId: string, force = false) => client.guilds.stickers.fetch(guildId, stickerId, force),
|
||||||
delete: (stickerId: string, reason?: string) => client.guilds.stickers.delete(guildId, stickerId, reason),
|
delete: (stickerId: string, reason?: string) => client.guilds.stickers.delete(guildId, stickerId, reason),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateStickerBodyRequest extends Omit<RESTPostAPIGuildStickerFormDataBody, 'file'> {
|
export interface CreateStickerBodyRequest extends Omit<RESTPostAPIGuildStickerFormDataBody, 'file'> {
|
||||||
file: Attachment;
|
file: Attachment | AttachmentBuilder | RawFile;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user