mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: add soundboard (#10590)
* feat: add soundboard * types(PartialSoundboardSound): add `available` * feat(VoiceChannelEffect): add `soundboardSound` getter * types: improve return types * docs: requested changes * feat: support multiple audio file types * types(GuildSoundboardSoundCreateOptions): add `contentType` * types: add default and guild soundboard sound * fix: requested changes * docs: use `@fires` tag * docs: remove misleading tag * chore: requested changes and missing things * feat: add send soundboard sound options
This commit is contained in:
@@ -142,6 +142,10 @@ test('teamIcon default', () => {
|
||||
expect(cdn.teamIcon(id, hash)).toEqual(`${baseCDN}/team-icons/${id}/${hash}.webp`);
|
||||
});
|
||||
|
||||
test('soundboardSound', () => {
|
||||
expect(cdn.soundboardSound(id)).toEqual(`${baseCDN}/soundboard-sounds/${id}`);
|
||||
});
|
||||
|
||||
test('makeURL throws on invalid size', () => {
|
||||
// @ts-expect-error: Invalid size
|
||||
expect(() => cdn.avatar(id, animatedHash, { size: 5 })).toThrow(RangeError);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* eslint-disable jsdoc/check-param-names */
|
||||
import { CDNRoutes } from 'discord-api-types/v10';
|
||||
import {
|
||||
ALLOWED_EXTENSIONS,
|
||||
ALLOWED_SIZES,
|
||||
@@ -288,6 +289,15 @@ export class CDN {
|
||||
return this.makeURL(`/guild-events/${scheduledEventId}/${coverHash}`, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a URL for a soundboard sound.
|
||||
*
|
||||
* @param soundId - The soundboard sound id
|
||||
*/
|
||||
public soundboardSound(soundId: string): string {
|
||||
return `${this.cdn}${CDNRoutes.soundboardSound(soundId)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user