feat: refresh discord attachment api

This commit is contained in:
Elysia
2024-11-08 14:31:37 +07:00
parent fb48a0dc7f
commit 44d7700296
2 changed files with 23 additions and 0 deletions

View File

@@ -517,6 +517,28 @@ class Client extends BaseClient {
return new Widget(this, data); return new Widget(this, data);
} }
/**
* Refresh the Discord CDN links with hashes so they can be usable.
* @param {string[]} urls Discord CDN URLs
* @returns {Promise<Array<{ original: string, refreshed: string }>>}
*/
async refreshAttachmentURL(urls) {
const data = await this.api.attachments('refresh-urls').post({
data: { attachment_urls: urls },
});
/**
{
"refreshed_urls": [
{
"original": "url",
"refreshed": "url with hash"
}
]
}
*/
return data.refreshed_urls;
}
/** /**
* Options for {@link Client#generateInvite}. * Options for {@link Client#generateInvite}.
* @typedef {Object} InviteGenerationOptions * @typedef {Object} InviteGenerationOptions

1
typings/index.d.ts vendored
View File

@@ -778,6 +778,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
public fetchPremiumStickerPacks(): Promise<Collection<Snowflake, StickerPack>>; public fetchPremiumStickerPacks(): Promise<Collection<Snowflake, StickerPack>>;
public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>; public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>;
public fetchGuildWidget(guild: GuildResolvable): Promise<Widget>; public fetchGuildWidget(guild: GuildResolvable): Promise<Widget>;
public refreshAttachmentURL(urls: string[]): Promise<{ original: string, refreshed: string }[]>
public sleep(timeout: number): Promise<void>; public sleep(timeout: number): Promise<void>;
public login(token?: string): Promise<string>; public login(token?: string): Promise<string>;
/** @deprecated This method will not be updated until I find the most convenient way to implement MFA. */ /** @deprecated This method will not be updated until I find the most convenient way to implement MFA. */