From 8d468300467db1c0a1726b4dfc6e92018e40e800 Mon Sep 17 00:00:00 2001 From: Danial Raza Date: Sun, 13 Oct 2024 18:03:05 +0200 Subject: [PATCH] feat: soundboard (#1113) Co-authored-by: Micah Benac --- deno/gateway/v10.ts | 142 +++++++++++++++++++++++++++----- deno/gateway/v9.ts | 142 +++++++++++++++++++++++++++----- deno/payloads/v10/guild.ts | 4 + deno/payloads/v10/mod.ts | 5 +- deno/payloads/v10/soundboard.ts | 44 ++++++++++ deno/payloads/v9/guild.ts | 4 + deno/payloads/v9/mod.ts | 5 +- deno/payloads/v9/soundboard.ts | 44 ++++++++++ deno/rest/common.ts | 4 + deno/rest/v10/mod.ts | 48 ++++++++++- deno/rest/v10/soundboard.ts | 107 ++++++++++++++++++++++++ deno/rest/v9/mod.ts | 48 ++++++++++- deno/rest/v9/soundboard.ts | 107 ++++++++++++++++++++++++ gateway/v10.ts | 142 +++++++++++++++++++++++++++----- gateway/v9.ts | 142 +++++++++++++++++++++++++++----- payloads/v10/guild.ts | 4 + payloads/v10/index.ts | 5 +- payloads/v10/soundboard.ts | 44 ++++++++++ payloads/v9/guild.ts | 4 + payloads/v9/index.ts | 5 +- payloads/v9/soundboard.ts | 44 ++++++++++ rest/common.ts | 4 + rest/v10/index.ts | 48 ++++++++++- rest/v10/soundboard.ts | 107 ++++++++++++++++++++++++ rest/v9/index.ts | 48 ++++++++++- rest/v9/soundboard.ts | 107 ++++++++++++++++++++++++ 26 files changed, 1312 insertions(+), 96 deletions(-) create mode 100644 deno/payloads/v10/soundboard.ts create mode 100644 deno/payloads/v9/soundboard.ts create mode 100644 deno/rest/v10/soundboard.ts create mode 100644 deno/rest/v9/soundboard.ts create mode 100644 payloads/v10/soundboard.ts create mode 100644 payloads/v9/soundboard.ts create mode 100644 rest/v10/soundboard.ts create mode 100644 rest/v9/soundboard.ts diff --git a/deno/gateway/v10.ts b/deno/gateway/v10.ts index a0a982ad..65dbef56 100644 --- a/deno/gateway/v10.ts +++ b/deno/gateway/v10.ts @@ -36,6 +36,7 @@ import type { APIEntitlement, ChannelType, APISubscription, + APISoundboardSound, } from '../payloads/v10/mod.ts'; import type { ReactionType } from '../rest/v10/mod.ts'; import type { Nullable } from '../utils/internals.ts'; @@ -93,6 +94,10 @@ export enum GatewayOpcodes { * Sent in response to receiving a heartbeat to acknowledge that it has been received */ HeartbeatAck, + /** + * Request information about soundboard sounds in a set of guilds + */ + RequestSoundboardSounds = 31, } /** @@ -214,10 +219,18 @@ export enum GatewayIntentBits { */ export enum GatewayDispatchEvents { ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE', + AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', + AutoModerationRuleCreate = 'AUTO_MODERATION_RULE_CREATE', + AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', + AutoModerationRuleUpdate = 'AUTO_MODERATION_RULE_UPDATE', ChannelCreate = 'CHANNEL_CREATE', ChannelDelete = 'CHANNEL_DELETE', ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', ChannelUpdate = 'CHANNEL_UPDATE', + EntitlementCreate = 'ENTITLEMENT_CREATE', + EntitlementDelete = 'ENTITLEMENT_DELETE', + EntitlementUpdate = 'ENTITLEMENT_UPDATE', + GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', GuildBanAdd = 'GUILD_BAN_ADD', GuildBanRemove = 'GUILD_BAN_REMOVE', GuildCreate = 'GUILD_CREATE', @@ -231,6 +244,15 @@ export enum GatewayDispatchEvents { GuildRoleCreate = 'GUILD_ROLE_CREATE', GuildRoleDelete = 'GUILD_ROLE_DELETE', GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', + GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', + GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', + GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', + GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', + GuildSoundboardSoundCreate = 'GUILD_SOUNDBOARD_SOUND_CREATE', + GuildSoundboardSoundDelete = 'GUILD_SOUNDBOARD_SOUND_DELETE', + GuildSoundboardSoundsUpdate = 'GUILD_SOUNDBOARD_SOUNDS_UPDATE', + GuildSoundboardSoundUpdate = 'GUILD_SOUNDBOARD_SOUND_UPDATE', GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', GuildUpdate = 'GUILD_UPDATE', IntegrationCreate = 'INTEGRATION_CREATE', @@ -242,17 +264,22 @@ export enum GatewayDispatchEvents { MessageCreate = 'MESSAGE_CREATE', MessageDelete = 'MESSAGE_DELETE', MessageDeleteBulk = 'MESSAGE_DELETE_BULK', + MessagePollVoteAdd = 'MESSAGE_POLL_VOTE_ADD', + MessagePollVoteRemove = 'MESSAGE_POLL_VOTE_REMOVE', MessageReactionAdd = 'MESSAGE_REACTION_ADD', MessageReactionRemove = 'MESSAGE_REACTION_REMOVE', MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL', MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI', MessageUpdate = 'MESSAGE_UPDATE', PresenceUpdate = 'PRESENCE_UPDATE', + Ready = 'READY', + Resumed = 'RESUMED', StageInstanceCreate = 'STAGE_INSTANCE_CREATE', StageInstanceDelete = 'STAGE_INSTANCE_DELETE', StageInstanceUpdate = 'STAGE_INSTANCE_UPDATE', - Ready = 'READY', - Resumed = 'RESUMED', + SubscriptionCreate = 'SUBSCRIPTION_CREATE', + SubscriptionDelete = 'SUBSCRIPTION_DELETE', + SubscriptionUpdate = 'SUBSCRIPTION_UPDATE', ThreadCreate = 'THREAD_CREATE', ThreadDelete = 'THREAD_DELETE', ThreadListSync = 'THREAD_LIST_SYNC', @@ -265,30 +292,13 @@ export enum GatewayDispatchEvents { VoiceServerUpdate = 'VOICE_SERVER_UPDATE', VoiceStateUpdate = 'VOICE_STATE_UPDATE', WebhooksUpdate = 'WEBHOOKS_UPDATE', - MessagePollVoteAdd = 'MESSAGE_POLL_VOTE_ADD', - MessagePollVoteRemove = 'MESSAGE_POLL_VOTE_REMOVE', - GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', - GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', - GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', - GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', - GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', - AutoModerationRuleCreate = 'AUTO_MODERATION_RULE_CREATE', - AutoModerationRuleUpdate = 'AUTO_MODERATION_RULE_UPDATE', - AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', - AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', - GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', - EntitlementCreate = 'ENTITLEMENT_CREATE', - EntitlementUpdate = 'ENTITLEMENT_UPDATE', - EntitlementDelete = 'ENTITLEMENT_DELETE', - SubscriptionCreate = 'SUBSCRIPTION_CREATE', - SubscriptionUpdate = 'SUBSCRIPTION_UPDATE', - SubscriptionDelete = 'SUBSCRIPTION_DELETE', } export type GatewaySendPayload = | GatewayHeartbeat | GatewayIdentify | GatewayRequestGuildMembers + | GatewayRequestSoundboardSounds | GatewayResume | GatewayUpdatePresence | GatewayVoiceStateUpdate; @@ -328,6 +338,10 @@ export type GatewayDispatchPayload = | GatewayGuildScheduledEventUpdateDispatch | GatewayGuildScheduledEventUserAddDispatch | GatewayGuildScheduledEventUserRemoveDispatch + | GatewayGuildSoundboardSoundCreateDispatch + | GatewayGuildSoundboardSoundDeleteDispatch + | GatewayGuildSoundboardSoundsUpdateDispatch + | GatewayGuildSoundboardSoundUpdateDispatch | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch @@ -1290,6 +1304,76 @@ export interface GatewayGuildScheduledEventUserRemoveDispatchData { guild_id: Snowflake; } +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + */ +export type GatewayGuildSoundboardSoundCreateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundCreate, + GatewayGuildSoundboardSoundCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + */ +export type GatewayGuildSoundboardSoundCreateDispatchData = APISoundboardSound; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-update + */ +export type GatewayGuildSoundboardSoundUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundUpdate, + GatewayGuildSoundboardSoundUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-update + */ +export type GatewayGuildSoundboardSoundUpdateDispatchData = APISoundboardSound; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + */ +export type GatewayGuildSoundboardSoundDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundDelete, + GatewayGuildSoundboardSoundDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + */ +export interface GatewayGuildSoundboardSoundDeleteDispatchData { + /** + * The id of the sound that was deleted + */ + sound_id: Snowflake; + /** + * The id of the guild the sound was in + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sounds-update + */ +export type GatewayGuildSoundboardSoundsUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundsUpdate, + GatewayGuildSoundboardSoundsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sounds-update + */ +export interface GatewayGuildSoundboardSoundsUpdateDispatchData { + /** + * The guild's soundboard sounds + */ + soundboard_sounds: APISoundboardSound[]; + /** + * The id of the guild + */ + guild_id: Snowflake; +} + /** * https://discord.com/developers/docs/topics/gateway-events#integration-create */ @@ -2199,6 +2283,24 @@ export type GatewayRequestGuildMembersData = | GatewayRequestGuildMembersDataWithQuery | GatewayRequestGuildMembersDataWithUserIds; +/** + * https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds + */ +export interface GatewayRequestSoundboardSounds { + op: GatewayOpcodes.RequestSoundboardSounds; + d: GatewayRequestSoundboardSoundsData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds + */ +export interface GatewayRequestSoundboardSoundsData { + /** + * The ids of the guilds to get soundboard sounds for + */ + guild_ids: Snowflake[]; +} + /** * https://discord.com/developers/docs/topics/gateway-events#update-voice-state */ diff --git a/deno/gateway/v9.ts b/deno/gateway/v9.ts index ad6bb279..ae8e16ca 100644 --- a/deno/gateway/v9.ts +++ b/deno/gateway/v9.ts @@ -35,6 +35,7 @@ import type { APIAuditLogEntry, ChannelType, APISubscription, + APISoundboardSound, } from '../payloads/v9/mod.ts'; import type { ReactionType } from '../rest/v9/mod.ts'; import type { Nullable } from '../utils/internals.ts'; @@ -93,6 +94,10 @@ export enum GatewayOpcodes { * Sent in response to receiving a heartbeat to acknowledge that it has been received */ HeartbeatAck, + /** + * Request information about soundboard sounds in a set of guilds + */ + RequestSoundboardSounds = 31, } /** @@ -213,10 +218,18 @@ export enum GatewayIntentBits { */ export enum GatewayDispatchEvents { ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE', + AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', + AutoModerationRuleCreate = 'AUTO_MODERATION_RULE_CREATE', + AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', + AutoModerationRuleUpdate = 'AUTO_MODERATION_RULE_UPDATE', ChannelCreate = 'CHANNEL_CREATE', ChannelDelete = 'CHANNEL_DELETE', ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', ChannelUpdate = 'CHANNEL_UPDATE', + EntitlementCreate = 'ENTITLEMENT_CREATE', + EntitlementDelete = 'ENTITLEMENT_DELETE', + EntitlementUpdate = 'ENTITLEMENT_UPDATE', + GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', GuildBanAdd = 'GUILD_BAN_ADD', GuildBanRemove = 'GUILD_BAN_REMOVE', GuildCreate = 'GUILD_CREATE', @@ -230,6 +243,15 @@ export enum GatewayDispatchEvents { GuildRoleCreate = 'GUILD_ROLE_CREATE', GuildRoleDelete = 'GUILD_ROLE_DELETE', GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', + GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', + GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', + GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', + GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', + GuildSoundboardSoundCreate = 'GUILD_SOUNDBOARD_SOUND_CREATE', + GuildSoundboardSoundDelete = 'GUILD_SOUNDBOARD_SOUND_DELETE', + GuildSoundboardSoundsUpdate = 'GUILD_SOUNDBOARD_SOUNDS_UPDATE', + GuildSoundboardSoundUpdate = 'GUILD_SOUNDBOARD_SOUND_UPDATE', GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', GuildUpdate = 'GUILD_UPDATE', IntegrationCreate = 'INTEGRATION_CREATE', @@ -241,17 +263,22 @@ export enum GatewayDispatchEvents { MessageCreate = 'MESSAGE_CREATE', MessageDelete = 'MESSAGE_DELETE', MessageDeleteBulk = 'MESSAGE_DELETE_BULK', + MessagePollVoteAdd = 'MESSAGE_POLL_VOTE_ADD', + MessagePollVoteRemove = 'MESSAGE_POLL_VOTE_REMOVE', MessageReactionAdd = 'MESSAGE_REACTION_ADD', MessageReactionRemove = 'MESSAGE_REACTION_REMOVE', MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL', MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI', MessageUpdate = 'MESSAGE_UPDATE', PresenceUpdate = 'PRESENCE_UPDATE', + Ready = 'READY', + Resumed = 'RESUMED', StageInstanceCreate = 'STAGE_INSTANCE_CREATE', StageInstanceDelete = 'STAGE_INSTANCE_DELETE', StageInstanceUpdate = 'STAGE_INSTANCE_UPDATE', - Ready = 'READY', - Resumed = 'RESUMED', + SubscriptionCreate = 'SUBSCRIPTION_CREATE', + SubscriptionDelete = 'SUBSCRIPTION_DELETE', + SubscriptionUpdate = 'SUBSCRIPTION_UPDATE', ThreadCreate = 'THREAD_CREATE', ThreadDelete = 'THREAD_DELETE', ThreadListSync = 'THREAD_LIST_SYNC', @@ -264,30 +291,13 @@ export enum GatewayDispatchEvents { VoiceServerUpdate = 'VOICE_SERVER_UPDATE', VoiceStateUpdate = 'VOICE_STATE_UPDATE', WebhooksUpdate = 'WEBHOOKS_UPDATE', - MessagePollVoteAdd = 'MESSAGE_POLL_VOTE_ADD', - MessagePollVoteRemove = 'MESSAGE_POLL_VOTE_REMOVE', - GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', - GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', - GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', - GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', - GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', - AutoModerationRuleCreate = 'AUTO_MODERATION_RULE_CREATE', - AutoModerationRuleUpdate = 'AUTO_MODERATION_RULE_UPDATE', - AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', - AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', - GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', - EntitlementCreate = 'ENTITLEMENT_CREATE', - EntitlementUpdate = 'ENTITLEMENT_UPDATE', - EntitlementDelete = 'ENTITLEMENT_DELETE', - SubscriptionCreate = 'SUBSCRIPTION_CREATE', - SubscriptionUpdate = 'SUBSCRIPTION_UPDATE', - SubscriptionDelete = 'SUBSCRIPTION_DELETE', } export type GatewaySendPayload = | GatewayHeartbeat | GatewayIdentify | GatewayRequestGuildMembers + | GatewayRequestSoundboardSounds | GatewayResume | GatewayUpdatePresence | GatewayVoiceStateUpdate; @@ -327,6 +337,10 @@ export type GatewayDispatchPayload = | GatewayGuildScheduledEventUpdateDispatch | GatewayGuildScheduledEventUserAddDispatch | GatewayGuildScheduledEventUserRemoveDispatch + | GatewayGuildSoundboardSoundCreateDispatch + | GatewayGuildSoundboardSoundDeleteDispatch + | GatewayGuildSoundboardSoundsUpdateDispatch + | GatewayGuildSoundboardSoundUpdateDispatch | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch @@ -1289,6 +1303,76 @@ export interface GatewayGuildScheduledEventUserRemoveDispatchData { guild_id: Snowflake; } +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + */ +export type GatewayGuildSoundboardSoundCreateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundCreate, + GatewayGuildSoundboardSoundCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + */ +export type GatewayGuildSoundboardSoundCreateDispatchData = APISoundboardSound; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-update + */ +export type GatewayGuildSoundboardSoundUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundUpdate, + GatewayGuildSoundboardSoundUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-update + */ +export type GatewayGuildSoundboardSoundUpdateDispatchData = APISoundboardSound; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + */ +export type GatewayGuildSoundboardSoundDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundDelete, + GatewayGuildSoundboardSoundDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + */ +export interface GatewayGuildSoundboardSoundDeleteDispatchData { + /** + * The id of the sound that was deleted + */ + sound_id: Snowflake; + /** + * The id of the guild the sound was in + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sounds-update + */ +export type GatewayGuildSoundboardSoundsUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundsUpdate, + GatewayGuildSoundboardSoundsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sounds-update + */ +export interface GatewayGuildSoundboardSoundsUpdateDispatchData { + /** + * The guild's soundboard sounds + */ + soundboard_sounds: APISoundboardSound[]; + /** + * The id of the guild + */ + guild_id: Snowflake; +} + /** * https://discord.com/developers/docs/topics/gateway-events#integration-create */ @@ -2198,6 +2282,24 @@ export type GatewayRequestGuildMembersData = | GatewayRequestGuildMembersDataWithQuery | GatewayRequestGuildMembersDataWithUserIds; +/** + * https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds + */ +export interface GatewayRequestSoundboardSounds { + op: GatewayOpcodes.RequestSoundboardSounds; + d: GatewayRequestSoundboardSoundsData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds + */ +export interface GatewayRequestSoundboardSoundsData { + /** + * The ids of the guilds to get soundboard sounds for + */ + guild_ids: Snowflake[]; +} + /** * https://discord.com/developers/docs/topics/gateway-events#update-voice-state */ diff --git a/deno/payloads/v10/guild.ts b/deno/payloads/v10/guild.ts index dea571fb..2a891750 100644 --- a/deno/payloads/v10/guild.ts +++ b/deno/payloads/v10/guild.ts @@ -534,6 +534,10 @@ export enum GuildFeature { * Guild has enabled the welcome screen */ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED', + /** + * Guild has created soundboard sounds + */ + Soundboard = 'SOUNDBOARD', } /** diff --git a/deno/payloads/v10/mod.ts b/deno/payloads/v10/mod.ts index fb0b509f..ce3f3f98 100644 --- a/deno/payloads/v10/mod.ts +++ b/deno/payloads/v10/mod.ts @@ -9,9 +9,11 @@ export * from './guild.ts'; export * from './guildScheduledEvent.ts'; export * from './interactions.ts'; export * from './invite.ts'; +export * from './monetization.ts'; export * from './oauth2.ts'; -export * from './poll.ts'; export * from './permissions.ts'; +export * from './poll.ts'; +export * from './soundboard.ts'; export * from './stageInstance.ts'; export * from './sticker.ts'; export * from './teams.ts'; @@ -19,4 +21,3 @@ export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; export * from './webhook.ts'; -export * from './monetization.ts'; diff --git a/deno/payloads/v10/soundboard.ts b/deno/payloads/v10/soundboard.ts new file mode 100644 index 00000000..1c6c74d5 --- /dev/null +++ b/deno/payloads/v10/soundboard.ts @@ -0,0 +1,44 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/soundboard + */ + +import type { Snowflake } from '../../globals.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/soundboard#soundboard-sound-object + */ +export interface APISoundboardSound { + /** + * The name of this sound + */ + name: string; + /** + * The id of this sound + */ + sound_id: Snowflake; + /** + * The volume of this sound, from 0 to 1 + */ + volume: number; + /** + * The id of this sound's custom emoji + */ + emoji_id: Snowflake | null; + /** + * The unicode character of this sound's standard emoji + */ + emoji_name: string | null; + /** + * The id of the guild that this sound is in + */ + guild_id?: Snowflake; + /** + * Whether this sound can be used (for guild sounds), may be false due to loss of Server Boosts + */ + available: boolean; + /** + * The user who created this sound + */ + user?: APIUser; +} diff --git a/deno/payloads/v9/guild.ts b/deno/payloads/v9/guild.ts index 42c16723..be0b6d1b 100644 --- a/deno/payloads/v9/guild.ts +++ b/deno/payloads/v9/guild.ts @@ -526,6 +526,10 @@ export enum GuildFeature { * Guild has enabled the welcome screen */ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED', + /** + * Guild has created soundboard sounds + */ + Soundboard = 'SOUNDBOARD', } /** diff --git a/deno/payloads/v9/mod.ts b/deno/payloads/v9/mod.ts index fb0b509f..ce3f3f98 100644 --- a/deno/payloads/v9/mod.ts +++ b/deno/payloads/v9/mod.ts @@ -9,9 +9,11 @@ export * from './guild.ts'; export * from './guildScheduledEvent.ts'; export * from './interactions.ts'; export * from './invite.ts'; +export * from './monetization.ts'; export * from './oauth2.ts'; -export * from './poll.ts'; export * from './permissions.ts'; +export * from './poll.ts'; +export * from './soundboard.ts'; export * from './stageInstance.ts'; export * from './sticker.ts'; export * from './teams.ts'; @@ -19,4 +21,3 @@ export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; export * from './webhook.ts'; -export * from './monetization.ts'; diff --git a/deno/payloads/v9/soundboard.ts b/deno/payloads/v9/soundboard.ts new file mode 100644 index 00000000..1c6c74d5 --- /dev/null +++ b/deno/payloads/v9/soundboard.ts @@ -0,0 +1,44 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/soundboard + */ + +import type { Snowflake } from '../../globals.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/soundboard#soundboard-sound-object + */ +export interface APISoundboardSound { + /** + * The name of this sound + */ + name: string; + /** + * The id of this sound + */ + sound_id: Snowflake; + /** + * The volume of this sound, from 0 to 1 + */ + volume: number; + /** + * The id of this sound's custom emoji + */ + emoji_id: Snowflake | null; + /** + * The unicode character of this sound's standard emoji + */ + emoji_name: string | null; + /** + * The id of the guild that this sound is in + */ + guild_id?: Snowflake; + /** + * Whether this sound can be used (for guild sounds), may be false due to loss of Server Boosts + */ + available: boolean; + /** + * The user who created this sound + */ + user?: APIUser; +} diff --git a/deno/rest/common.ts b/deno/rest/common.ts index 894f7209..df82d48e 100644 --- a/deno/rest/common.ts +++ b/deno/rest/common.ts @@ -22,6 +22,7 @@ export enum RESTJSONErrorCodes { UnknownWebhookService, UnknownSession = 10_020, + UnknownAsset, UnknownBan = 10_026, UnknownSKU, @@ -234,6 +235,9 @@ export enum RESTJSONErrorCodes { ServerNeedsMoreBoostsToPerformThisAction = 50_101, RequestBodyContainsInvalidJSON = 50_109, + ProvidedFileIsInvalid, + + ProvidedFileDurationExceedsMaximumLength = 50_124, OwnerCannotBePendingMember = 50_131, OwnershipCannotBeMovedToABotUser, diff --git a/deno/rest/v10/mod.ts b/deno/rest/v10/mod.ts index 0c0d5b59..aaebaba6 100644 --- a/deno/rest/v10/mod.ts +++ b/deno/rest/v10/mod.ts @@ -11,15 +11,16 @@ export * from './guild.ts'; export * from './guildScheduledEvent.ts'; export * from './interactions.ts'; export * from './invite.ts'; +export * from './monetization.ts'; export * from './oauth2.ts'; export * from './poll.ts'; +export * from './soundboard.ts'; export * from './stageInstance.ts'; export * from './sticker.ts'; export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; export * from './webhook.ts'; -export * from './monetization.ts'; export const APIVersion = '10'; @@ -1010,11 +1011,46 @@ export const Routes = { /** * Route for: - * - GET `/skus/{sku.id}/subscriptions/${subscription.id}` + * - GET `/skus/{sku.id}/subscriptions/{subscription.id}` */ skuSubscription(skuId: Snowflake, subscriptionId: Snowflake) { return `/skus/${skuId}/subscriptions/${subscriptionId}` as const; }, + + /** + * Route for: + * - POST `/channels/{channel.id}/send-soundboard-sound` + */ + sendSoundboardSound(channelId: Snowflake) { + return `/channels/${channelId}/send-soundboard-sound` as const; + }, + + /** + * Route for: + * - GET `/soundboard-default-sounds` + */ + soundboardDefaultSounds() { + return '/soundboard-default-sounds' as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/soundboard-sounds` + * - POST `/guilds/{guild.id}/soundboard-sounds` + */ + guildSoundboardSounds(guildId: Snowflake) { + return `/guilds/${guildId}/soundboard-sounds` as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + * - PATCH `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + * - DELETE `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + */ + guildSoundboardSound(guildId: Snowflake, soundId: Snowflake) { + return `/guilds/${guildId}/soundboard-sounds/${soundId}` as const; + }, }; export const StickerPackApplicationId = '710982414301790216'; @@ -1304,6 +1340,14 @@ export const CDNRoutes = { ) { return `/guilds/${guildId}/users/${userId}/banners/${guildMemberBanner}.${format}` as const; }, + + /** + * Route for: + * - GET `/soundboard-sounds/${sound.id}` + */ + soundboardSound(soundId: Snowflake) { + return `/soundboard-sounds/${soundId}` as const; + }, }; export type DefaultUserAvatarAssets = 0 | 1 | 2 | 3 | 4 | 5; diff --git a/deno/rest/v10/soundboard.ts b/deno/rest/v10/soundboard.ts new file mode 100644 index 00000000..673c0afb --- /dev/null +++ b/deno/rest/v10/soundboard.ts @@ -0,0 +1,107 @@ +import type { Snowflake } from '../../globals.ts'; +import type { APISoundboardSound } from '../../payloads/v10/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound + */ +export type RESTPostAPISendSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound-json-params + */ +export interface RESTPostAPISoundboardSendSoundJSONBody { + /** + * The id of the soundboard sound to play + */ + sound_id: Snowflake; + /** + * The id of the guild the soundboard sound is from, required to play sounds from different servers + */ + source_guild_id?: Snowflake | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#list-soundboard-default-sounds + */ +export type RESTGetAPISoundboardDefaultSoundsResult = APISoundboardSound[]; + +/** + * https://discord.com/developers/docs/resources/soundboard#list-guild-soundboard-sounds + */ +export interface RESTGetAPIGuildSoundboardSoundsResult { + items: APISoundboardSound[]; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#get-guild-soundboard-sound + */ +export type RESTGetAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound-json-params + */ +export interface RESTPostAPIGuildSoundboardSoundJSONBody { + /** + * The name of the soundboard sound (2-32 characters) + */ + name: string; + /** + * The data uri of the mp3 or ogg sound data, base64 encoded, similar to image data + * + * See https://discord.com/developers/docs/reference#image-data + */ + sound: string; + /** + * The volume of the soundboard sound, from 0 to 1 + * + * @default 1 + */ + volume?: number | null | undefined; + /** + * The id of the custom emoji for the soundboard sound + */ + emoji_id?: Snowflake | null | undefined; + /** + * The unicode character of a standard emoji for the soundboard sound + */ + emoji_name?: string | null | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound + */ +export type RESTPostAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound-json-params + */ +export interface RESTPatchAPIGuildSoundboardSoundJSONBody { + /** + * The name of the soundboard sound (2-32 characters) + */ + name?: string | undefined; + /** + * The volume of the soundboard sound, from 0 to 1 + * + * @default 1 + */ + volume?: number | null | undefined; + /** + * The id of the custom emoji for the soundboard sound + */ + emoji_id?: Snowflake | null | undefined; + /** + * The unicode character of a standard emoji for the soundboard sound + */ + emoji_name?: string | null | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound + */ +export type RESTPatchAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#delete-guild-soundboard-sound + */ +export type RESTDeleteAPIGuildSoundboardSoundResult = never; diff --git a/deno/rest/v9/mod.ts b/deno/rest/v9/mod.ts index f3689621..426084a4 100644 --- a/deno/rest/v9/mod.ts +++ b/deno/rest/v9/mod.ts @@ -11,15 +11,16 @@ export * from './guild.ts'; export * from './guildScheduledEvent.ts'; export * from './interactions.ts'; export * from './invite.ts'; +export * from './monetization.ts'; export * from './oauth2.ts'; export * from './poll.ts'; +export * from './soundboard.ts'; export * from './stageInstance.ts'; export * from './sticker.ts'; export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; export * from './webhook.ts'; -export * from './monetization.ts'; export const APIVersion = '9'; @@ -1019,11 +1020,46 @@ export const Routes = { /** * Route for: - * - GET `/skus/{sku.id}/subscriptions/${subscription.id}` + * - GET `/skus/{sku.id}/subscriptions/{subscription.id}` */ skuSubscription(skuId: Snowflake, subscriptionId: Snowflake) { return `/skus/${skuId}/subscriptions/${subscriptionId}` as const; }, + + /** + * Route for: + * - POST `/channels/{channel.id}/send-soundboard-sound` + */ + sendSoundboardSound(channelId: Snowflake) { + return `/channels/${channelId}/send-soundboard-sound` as const; + }, + + /** + * Route for: + * - GET `/soundboard-default-sounds` + */ + soundboardDefaultSounds() { + return '/soundboard-default-sounds' as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/soundboard-sounds` + * - POST `/guilds/{guild.id}/soundboard-sounds` + */ + guildSoundboardSounds(guildId: Snowflake) { + return `/guilds/${guildId}/soundboard-sounds` as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + * - PATCH `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + * - DELETE `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + */ + guildSoundboardSound(guildId: Snowflake, soundId: Snowflake) { + return `/guilds/${guildId}/soundboard-sounds/${soundId}` as const; + }, }; export const StickerPackApplicationId = '710982414301790216'; @@ -1313,6 +1349,14 @@ export const CDNRoutes = { ) { return `/guilds/${guildId}/users/${userId}/banners/${guildMemberBanner}.${format}` as const; }, + + /** + * Route for: + * - GET `/soundboard-sounds/${sound.id}` + */ + soundboardSound(soundId: Snowflake) { + return `/soundboard-sounds/${soundId}` as const; + }, }; export type DefaultUserAvatarAssets = 0 | 1 | 2 | 3 | 4 | 5; diff --git a/deno/rest/v9/soundboard.ts b/deno/rest/v9/soundboard.ts new file mode 100644 index 00000000..673c0afb --- /dev/null +++ b/deno/rest/v9/soundboard.ts @@ -0,0 +1,107 @@ +import type { Snowflake } from '../../globals.ts'; +import type { APISoundboardSound } from '../../payloads/v10/mod.ts'; + +/** + * https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound + */ +export type RESTPostAPISendSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound-json-params + */ +export interface RESTPostAPISoundboardSendSoundJSONBody { + /** + * The id of the soundboard sound to play + */ + sound_id: Snowflake; + /** + * The id of the guild the soundboard sound is from, required to play sounds from different servers + */ + source_guild_id?: Snowflake | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#list-soundboard-default-sounds + */ +export type RESTGetAPISoundboardDefaultSoundsResult = APISoundboardSound[]; + +/** + * https://discord.com/developers/docs/resources/soundboard#list-guild-soundboard-sounds + */ +export interface RESTGetAPIGuildSoundboardSoundsResult { + items: APISoundboardSound[]; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#get-guild-soundboard-sound + */ +export type RESTGetAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound-json-params + */ +export interface RESTPostAPIGuildSoundboardSoundJSONBody { + /** + * The name of the soundboard sound (2-32 characters) + */ + name: string; + /** + * The data uri of the mp3 or ogg sound data, base64 encoded, similar to image data + * + * See https://discord.com/developers/docs/reference#image-data + */ + sound: string; + /** + * The volume of the soundboard sound, from 0 to 1 + * + * @default 1 + */ + volume?: number | null | undefined; + /** + * The id of the custom emoji for the soundboard sound + */ + emoji_id?: Snowflake | null | undefined; + /** + * The unicode character of a standard emoji for the soundboard sound + */ + emoji_name?: string | null | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound + */ +export type RESTPostAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound-json-params + */ +export interface RESTPatchAPIGuildSoundboardSoundJSONBody { + /** + * The name of the soundboard sound (2-32 characters) + */ + name?: string | undefined; + /** + * The volume of the soundboard sound, from 0 to 1 + * + * @default 1 + */ + volume?: number | null | undefined; + /** + * The id of the custom emoji for the soundboard sound + */ + emoji_id?: Snowflake | null | undefined; + /** + * The unicode character of a standard emoji for the soundboard sound + */ + emoji_name?: string | null | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound + */ +export type RESTPatchAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#delete-guild-soundboard-sound + */ +export type RESTDeleteAPIGuildSoundboardSoundResult = never; diff --git a/gateway/v10.ts b/gateway/v10.ts index a8f7b3ad..aa656ae3 100644 --- a/gateway/v10.ts +++ b/gateway/v10.ts @@ -36,6 +36,7 @@ import type { APIEntitlement, ChannelType, APISubscription, + APISoundboardSound, } from '../payloads/v10/index'; import type { ReactionType } from '../rest/v10/index'; import type { Nullable } from '../utils/internals'; @@ -93,6 +94,10 @@ export enum GatewayOpcodes { * Sent in response to receiving a heartbeat to acknowledge that it has been received */ HeartbeatAck, + /** + * Request information about soundboard sounds in a set of guilds + */ + RequestSoundboardSounds = 31, } /** @@ -214,10 +219,18 @@ export enum GatewayIntentBits { */ export enum GatewayDispatchEvents { ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE', + AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', + AutoModerationRuleCreate = 'AUTO_MODERATION_RULE_CREATE', + AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', + AutoModerationRuleUpdate = 'AUTO_MODERATION_RULE_UPDATE', ChannelCreate = 'CHANNEL_CREATE', ChannelDelete = 'CHANNEL_DELETE', ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', ChannelUpdate = 'CHANNEL_UPDATE', + EntitlementCreate = 'ENTITLEMENT_CREATE', + EntitlementDelete = 'ENTITLEMENT_DELETE', + EntitlementUpdate = 'ENTITLEMENT_UPDATE', + GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', GuildBanAdd = 'GUILD_BAN_ADD', GuildBanRemove = 'GUILD_BAN_REMOVE', GuildCreate = 'GUILD_CREATE', @@ -231,6 +244,15 @@ export enum GatewayDispatchEvents { GuildRoleCreate = 'GUILD_ROLE_CREATE', GuildRoleDelete = 'GUILD_ROLE_DELETE', GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', + GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', + GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', + GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', + GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', + GuildSoundboardSoundCreate = 'GUILD_SOUNDBOARD_SOUND_CREATE', + GuildSoundboardSoundDelete = 'GUILD_SOUNDBOARD_SOUND_DELETE', + GuildSoundboardSoundsUpdate = 'GUILD_SOUNDBOARD_SOUNDS_UPDATE', + GuildSoundboardSoundUpdate = 'GUILD_SOUNDBOARD_SOUND_UPDATE', GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', GuildUpdate = 'GUILD_UPDATE', IntegrationCreate = 'INTEGRATION_CREATE', @@ -242,17 +264,22 @@ export enum GatewayDispatchEvents { MessageCreate = 'MESSAGE_CREATE', MessageDelete = 'MESSAGE_DELETE', MessageDeleteBulk = 'MESSAGE_DELETE_BULK', + MessagePollVoteAdd = 'MESSAGE_POLL_VOTE_ADD', + MessagePollVoteRemove = 'MESSAGE_POLL_VOTE_REMOVE', MessageReactionAdd = 'MESSAGE_REACTION_ADD', MessageReactionRemove = 'MESSAGE_REACTION_REMOVE', MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL', MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI', MessageUpdate = 'MESSAGE_UPDATE', PresenceUpdate = 'PRESENCE_UPDATE', + Ready = 'READY', + Resumed = 'RESUMED', StageInstanceCreate = 'STAGE_INSTANCE_CREATE', StageInstanceDelete = 'STAGE_INSTANCE_DELETE', StageInstanceUpdate = 'STAGE_INSTANCE_UPDATE', - Ready = 'READY', - Resumed = 'RESUMED', + SubscriptionCreate = 'SUBSCRIPTION_CREATE', + SubscriptionDelete = 'SUBSCRIPTION_DELETE', + SubscriptionUpdate = 'SUBSCRIPTION_UPDATE', ThreadCreate = 'THREAD_CREATE', ThreadDelete = 'THREAD_DELETE', ThreadListSync = 'THREAD_LIST_SYNC', @@ -265,30 +292,13 @@ export enum GatewayDispatchEvents { VoiceServerUpdate = 'VOICE_SERVER_UPDATE', VoiceStateUpdate = 'VOICE_STATE_UPDATE', WebhooksUpdate = 'WEBHOOKS_UPDATE', - MessagePollVoteAdd = 'MESSAGE_POLL_VOTE_ADD', - MessagePollVoteRemove = 'MESSAGE_POLL_VOTE_REMOVE', - GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', - GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', - GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', - GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', - GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', - AutoModerationRuleCreate = 'AUTO_MODERATION_RULE_CREATE', - AutoModerationRuleUpdate = 'AUTO_MODERATION_RULE_UPDATE', - AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', - AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', - GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', - EntitlementCreate = 'ENTITLEMENT_CREATE', - EntitlementUpdate = 'ENTITLEMENT_UPDATE', - EntitlementDelete = 'ENTITLEMENT_DELETE', - SubscriptionCreate = 'SUBSCRIPTION_CREATE', - SubscriptionUpdate = 'SUBSCRIPTION_UPDATE', - SubscriptionDelete = 'SUBSCRIPTION_DELETE', } export type GatewaySendPayload = | GatewayHeartbeat | GatewayIdentify | GatewayRequestGuildMembers + | GatewayRequestSoundboardSounds | GatewayResume | GatewayUpdatePresence | GatewayVoiceStateUpdate; @@ -328,6 +338,10 @@ export type GatewayDispatchPayload = | GatewayGuildScheduledEventUpdateDispatch | GatewayGuildScheduledEventUserAddDispatch | GatewayGuildScheduledEventUserRemoveDispatch + | GatewayGuildSoundboardSoundCreateDispatch + | GatewayGuildSoundboardSoundDeleteDispatch + | GatewayGuildSoundboardSoundsUpdateDispatch + | GatewayGuildSoundboardSoundUpdateDispatch | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch @@ -1290,6 +1304,76 @@ export interface GatewayGuildScheduledEventUserRemoveDispatchData { guild_id: Snowflake; } +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + */ +export type GatewayGuildSoundboardSoundCreateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundCreate, + GatewayGuildSoundboardSoundCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + */ +export type GatewayGuildSoundboardSoundCreateDispatchData = APISoundboardSound; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-update + */ +export type GatewayGuildSoundboardSoundUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundUpdate, + GatewayGuildSoundboardSoundUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-update + */ +export type GatewayGuildSoundboardSoundUpdateDispatchData = APISoundboardSound; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + */ +export type GatewayGuildSoundboardSoundDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundDelete, + GatewayGuildSoundboardSoundDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + */ +export interface GatewayGuildSoundboardSoundDeleteDispatchData { + /** + * The id of the sound that was deleted + */ + sound_id: Snowflake; + /** + * The id of the guild the sound was in + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sounds-update + */ +export type GatewayGuildSoundboardSoundsUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundsUpdate, + GatewayGuildSoundboardSoundsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sounds-update + */ +export interface GatewayGuildSoundboardSoundsUpdateDispatchData { + /** + * The guild's soundboard sounds + */ + soundboard_sounds: APISoundboardSound[]; + /** + * The id of the guild + */ + guild_id: Snowflake; +} + /** * https://discord.com/developers/docs/topics/gateway-events#integration-create */ @@ -2199,6 +2283,24 @@ export type GatewayRequestGuildMembersData = | GatewayRequestGuildMembersDataWithQuery | GatewayRequestGuildMembersDataWithUserIds; +/** + * https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds + */ +export interface GatewayRequestSoundboardSounds { + op: GatewayOpcodes.RequestSoundboardSounds; + d: GatewayRequestSoundboardSoundsData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds + */ +export interface GatewayRequestSoundboardSoundsData { + /** + * The ids of the guilds to get soundboard sounds for + */ + guild_ids: Snowflake[]; +} + /** * https://discord.com/developers/docs/topics/gateway-events#update-voice-state */ diff --git a/gateway/v9.ts b/gateway/v9.ts index 8b7b4b94..c25f906e 100644 --- a/gateway/v9.ts +++ b/gateway/v9.ts @@ -35,6 +35,7 @@ import type { APIAuditLogEntry, ChannelType, APISubscription, + APISoundboardSound, } from '../payloads/v9/index'; import type { ReactionType } from '../rest/v9/index'; import type { Nullable } from '../utils/internals'; @@ -93,6 +94,10 @@ export enum GatewayOpcodes { * Sent in response to receiving a heartbeat to acknowledge that it has been received */ HeartbeatAck, + /** + * Request information about soundboard sounds in a set of guilds + */ + RequestSoundboardSounds = 31, } /** @@ -213,10 +218,18 @@ export enum GatewayIntentBits { */ export enum GatewayDispatchEvents { ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE', + AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', + AutoModerationRuleCreate = 'AUTO_MODERATION_RULE_CREATE', + AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', + AutoModerationRuleUpdate = 'AUTO_MODERATION_RULE_UPDATE', ChannelCreate = 'CHANNEL_CREATE', ChannelDelete = 'CHANNEL_DELETE', ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', ChannelUpdate = 'CHANNEL_UPDATE', + EntitlementCreate = 'ENTITLEMENT_CREATE', + EntitlementDelete = 'ENTITLEMENT_DELETE', + EntitlementUpdate = 'ENTITLEMENT_UPDATE', + GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', GuildBanAdd = 'GUILD_BAN_ADD', GuildBanRemove = 'GUILD_BAN_REMOVE', GuildCreate = 'GUILD_CREATE', @@ -230,6 +243,15 @@ export enum GatewayDispatchEvents { GuildRoleCreate = 'GUILD_ROLE_CREATE', GuildRoleDelete = 'GUILD_ROLE_DELETE', GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', + GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', + GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', + GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', + GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', + GuildSoundboardSoundCreate = 'GUILD_SOUNDBOARD_SOUND_CREATE', + GuildSoundboardSoundDelete = 'GUILD_SOUNDBOARD_SOUND_DELETE', + GuildSoundboardSoundsUpdate = 'GUILD_SOUNDBOARD_SOUNDS_UPDATE', + GuildSoundboardSoundUpdate = 'GUILD_SOUNDBOARD_SOUND_UPDATE', GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', GuildUpdate = 'GUILD_UPDATE', IntegrationCreate = 'INTEGRATION_CREATE', @@ -241,17 +263,22 @@ export enum GatewayDispatchEvents { MessageCreate = 'MESSAGE_CREATE', MessageDelete = 'MESSAGE_DELETE', MessageDeleteBulk = 'MESSAGE_DELETE_BULK', + MessagePollVoteAdd = 'MESSAGE_POLL_VOTE_ADD', + MessagePollVoteRemove = 'MESSAGE_POLL_VOTE_REMOVE', MessageReactionAdd = 'MESSAGE_REACTION_ADD', MessageReactionRemove = 'MESSAGE_REACTION_REMOVE', MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL', MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI', MessageUpdate = 'MESSAGE_UPDATE', PresenceUpdate = 'PRESENCE_UPDATE', + Ready = 'READY', + Resumed = 'RESUMED', StageInstanceCreate = 'STAGE_INSTANCE_CREATE', StageInstanceDelete = 'STAGE_INSTANCE_DELETE', StageInstanceUpdate = 'STAGE_INSTANCE_UPDATE', - Ready = 'READY', - Resumed = 'RESUMED', + SubscriptionCreate = 'SUBSCRIPTION_CREATE', + SubscriptionDelete = 'SUBSCRIPTION_DELETE', + SubscriptionUpdate = 'SUBSCRIPTION_UPDATE', ThreadCreate = 'THREAD_CREATE', ThreadDelete = 'THREAD_DELETE', ThreadListSync = 'THREAD_LIST_SYNC', @@ -264,30 +291,13 @@ export enum GatewayDispatchEvents { VoiceServerUpdate = 'VOICE_SERVER_UPDATE', VoiceStateUpdate = 'VOICE_STATE_UPDATE', WebhooksUpdate = 'WEBHOOKS_UPDATE', - MessagePollVoteAdd = 'MESSAGE_POLL_VOTE_ADD', - MessagePollVoteRemove = 'MESSAGE_POLL_VOTE_REMOVE', - GuildScheduledEventCreate = 'GUILD_SCHEDULED_EVENT_CREATE', - GuildScheduledEventUpdate = 'GUILD_SCHEDULED_EVENT_UPDATE', - GuildScheduledEventDelete = 'GUILD_SCHEDULED_EVENT_DELETE', - GuildScheduledEventUserAdd = 'GUILD_SCHEDULED_EVENT_USER_ADD', - GuildScheduledEventUserRemove = 'GUILD_SCHEDULED_EVENT_USER_REMOVE', - AutoModerationRuleCreate = 'AUTO_MODERATION_RULE_CREATE', - AutoModerationRuleUpdate = 'AUTO_MODERATION_RULE_UPDATE', - AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', - AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', - GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', - EntitlementCreate = 'ENTITLEMENT_CREATE', - EntitlementUpdate = 'ENTITLEMENT_UPDATE', - EntitlementDelete = 'ENTITLEMENT_DELETE', - SubscriptionCreate = 'SUBSCRIPTION_CREATE', - SubscriptionUpdate = 'SUBSCRIPTION_UPDATE', - SubscriptionDelete = 'SUBSCRIPTION_DELETE', } export type GatewaySendPayload = | GatewayHeartbeat | GatewayIdentify | GatewayRequestGuildMembers + | GatewayRequestSoundboardSounds | GatewayResume | GatewayUpdatePresence | GatewayVoiceStateUpdate; @@ -327,6 +337,10 @@ export type GatewayDispatchPayload = | GatewayGuildScheduledEventUpdateDispatch | GatewayGuildScheduledEventUserAddDispatch | GatewayGuildScheduledEventUserRemoveDispatch + | GatewayGuildSoundboardSoundCreateDispatch + | GatewayGuildSoundboardSoundDeleteDispatch + | GatewayGuildSoundboardSoundsUpdateDispatch + | GatewayGuildSoundboardSoundUpdateDispatch | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch @@ -1289,6 +1303,76 @@ export interface GatewayGuildScheduledEventUserRemoveDispatchData { guild_id: Snowflake; } +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + */ +export type GatewayGuildSoundboardSoundCreateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundCreate, + GatewayGuildSoundboardSoundCreateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + */ +export type GatewayGuildSoundboardSoundCreateDispatchData = APISoundboardSound; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-update + */ +export type GatewayGuildSoundboardSoundUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundUpdate, + GatewayGuildSoundboardSoundUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-update + */ +export type GatewayGuildSoundboardSoundUpdateDispatchData = APISoundboardSound; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + */ +export type GatewayGuildSoundboardSoundDeleteDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundDelete, + GatewayGuildSoundboardSoundDeleteDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + */ +export interface GatewayGuildSoundboardSoundDeleteDispatchData { + /** + * The id of the sound that was deleted + */ + sound_id: Snowflake; + /** + * The id of the guild the sound was in + */ + guild_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sounds-update + */ +export type GatewayGuildSoundboardSoundsUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildSoundboardSoundsUpdate, + GatewayGuildSoundboardSoundsUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sounds-update + */ +export interface GatewayGuildSoundboardSoundsUpdateDispatchData { + /** + * The guild's soundboard sounds + */ + soundboard_sounds: APISoundboardSound[]; + /** + * The id of the guild + */ + guild_id: Snowflake; +} + /** * https://discord.com/developers/docs/topics/gateway-events#integration-create */ @@ -2198,6 +2282,24 @@ export type GatewayRequestGuildMembersData = | GatewayRequestGuildMembersDataWithQuery | GatewayRequestGuildMembersDataWithUserIds; +/** + * https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds + */ +export interface GatewayRequestSoundboardSounds { + op: GatewayOpcodes.RequestSoundboardSounds; + d: GatewayRequestSoundboardSoundsData; +} + +/** + * https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds + */ +export interface GatewayRequestSoundboardSoundsData { + /** + * The ids of the guilds to get soundboard sounds for + */ + guild_ids: Snowflake[]; +} + /** * https://discord.com/developers/docs/topics/gateway-events#update-voice-state */ diff --git a/payloads/v10/guild.ts b/payloads/v10/guild.ts index 55c136fa..19cef047 100644 --- a/payloads/v10/guild.ts +++ b/payloads/v10/guild.ts @@ -534,6 +534,10 @@ export enum GuildFeature { * Guild has enabled the welcome screen */ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED', + /** + * Guild has created soundboard sounds + */ + Soundboard = 'SOUNDBOARD', } /** diff --git a/payloads/v10/index.ts b/payloads/v10/index.ts index a30701a6..454c278a 100644 --- a/payloads/v10/index.ts +++ b/payloads/v10/index.ts @@ -9,9 +9,11 @@ export * from './guild'; export * from './guildScheduledEvent'; export * from './interactions'; export * from './invite'; +export * from './monetization'; export * from './oauth2'; -export * from './poll'; export * from './permissions'; +export * from './poll'; +export * from './soundboard'; export * from './stageInstance'; export * from './sticker'; export * from './teams'; @@ -19,4 +21,3 @@ export * from './template'; export * from './user'; export * from './voice'; export * from './webhook'; -export * from './monetization'; diff --git a/payloads/v10/soundboard.ts b/payloads/v10/soundboard.ts new file mode 100644 index 00000000..ea4509be --- /dev/null +++ b/payloads/v10/soundboard.ts @@ -0,0 +1,44 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/soundboard + */ + +import type { Snowflake } from '../../globals'; +import type { APIUser } from './user'; + +/** + * https://discord.com/developers/docs/resources/soundboard#soundboard-sound-object + */ +export interface APISoundboardSound { + /** + * The name of this sound + */ + name: string; + /** + * The id of this sound + */ + sound_id: Snowflake; + /** + * The volume of this sound, from 0 to 1 + */ + volume: number; + /** + * The id of this sound's custom emoji + */ + emoji_id: Snowflake | null; + /** + * The unicode character of this sound's standard emoji + */ + emoji_name: string | null; + /** + * The id of the guild that this sound is in + */ + guild_id?: Snowflake; + /** + * Whether this sound can be used (for guild sounds), may be false due to loss of Server Boosts + */ + available: boolean; + /** + * The user who created this sound + */ + user?: APIUser; +} diff --git a/payloads/v9/guild.ts b/payloads/v9/guild.ts index 28325b0f..384f4352 100644 --- a/payloads/v9/guild.ts +++ b/payloads/v9/guild.ts @@ -526,6 +526,10 @@ export enum GuildFeature { * Guild has enabled the welcome screen */ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED', + /** + * Guild has created soundboard sounds + */ + Soundboard = 'SOUNDBOARD', } /** diff --git a/payloads/v9/index.ts b/payloads/v9/index.ts index a30701a6..454c278a 100644 --- a/payloads/v9/index.ts +++ b/payloads/v9/index.ts @@ -9,9 +9,11 @@ export * from './guild'; export * from './guildScheduledEvent'; export * from './interactions'; export * from './invite'; +export * from './monetization'; export * from './oauth2'; -export * from './poll'; export * from './permissions'; +export * from './poll'; +export * from './soundboard'; export * from './stageInstance'; export * from './sticker'; export * from './teams'; @@ -19,4 +21,3 @@ export * from './template'; export * from './user'; export * from './voice'; export * from './webhook'; -export * from './monetization'; diff --git a/payloads/v9/soundboard.ts b/payloads/v9/soundboard.ts new file mode 100644 index 00000000..ea4509be --- /dev/null +++ b/payloads/v9/soundboard.ts @@ -0,0 +1,44 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/soundboard + */ + +import type { Snowflake } from '../../globals'; +import type { APIUser } from './user'; + +/** + * https://discord.com/developers/docs/resources/soundboard#soundboard-sound-object + */ +export interface APISoundboardSound { + /** + * The name of this sound + */ + name: string; + /** + * The id of this sound + */ + sound_id: Snowflake; + /** + * The volume of this sound, from 0 to 1 + */ + volume: number; + /** + * The id of this sound's custom emoji + */ + emoji_id: Snowflake | null; + /** + * The unicode character of this sound's standard emoji + */ + emoji_name: string | null; + /** + * The id of the guild that this sound is in + */ + guild_id?: Snowflake; + /** + * Whether this sound can be used (for guild sounds), may be false due to loss of Server Boosts + */ + available: boolean; + /** + * The user who created this sound + */ + user?: APIUser; +} diff --git a/rest/common.ts b/rest/common.ts index 894f7209..df82d48e 100644 --- a/rest/common.ts +++ b/rest/common.ts @@ -22,6 +22,7 @@ export enum RESTJSONErrorCodes { UnknownWebhookService, UnknownSession = 10_020, + UnknownAsset, UnknownBan = 10_026, UnknownSKU, @@ -234,6 +235,9 @@ export enum RESTJSONErrorCodes { ServerNeedsMoreBoostsToPerformThisAction = 50_101, RequestBodyContainsInvalidJSON = 50_109, + ProvidedFileIsInvalid, + + ProvidedFileDurationExceedsMaximumLength = 50_124, OwnerCannotBePendingMember = 50_131, OwnershipCannotBeMovedToABotUser, diff --git a/rest/v10/index.ts b/rest/v10/index.ts index 7d3804bf..80f00814 100644 --- a/rest/v10/index.ts +++ b/rest/v10/index.ts @@ -11,15 +11,16 @@ export * from './guild'; export * from './guildScheduledEvent'; export * from './interactions'; export * from './invite'; +export * from './monetization'; export * from './oauth2'; export * from './poll'; +export * from './soundboard'; export * from './stageInstance'; export * from './sticker'; export * from './template'; export * from './user'; export * from './voice'; export * from './webhook'; -export * from './monetization'; export const APIVersion = '10'; @@ -1010,11 +1011,46 @@ export const Routes = { /** * Route for: - * - GET `/skus/{sku.id}/subscriptions/${subscription.id}` + * - GET `/skus/{sku.id}/subscriptions/{subscription.id}` */ skuSubscription(skuId: Snowflake, subscriptionId: Snowflake) { return `/skus/${skuId}/subscriptions/${subscriptionId}` as const; }, + + /** + * Route for: + * - POST `/channels/{channel.id}/send-soundboard-sound` + */ + sendSoundboardSound(channelId: Snowflake) { + return `/channels/${channelId}/send-soundboard-sound` as const; + }, + + /** + * Route for: + * - GET `/soundboard-default-sounds` + */ + soundboardDefaultSounds() { + return '/soundboard-default-sounds' as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/soundboard-sounds` + * - POST `/guilds/{guild.id}/soundboard-sounds` + */ + guildSoundboardSounds(guildId: Snowflake) { + return `/guilds/${guildId}/soundboard-sounds` as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + * - PATCH `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + * - DELETE `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + */ + guildSoundboardSound(guildId: Snowflake, soundId: Snowflake) { + return `/guilds/${guildId}/soundboard-sounds/${soundId}` as const; + }, }; export const StickerPackApplicationId = '710982414301790216'; @@ -1304,6 +1340,14 @@ export const CDNRoutes = { ) { return `/guilds/${guildId}/users/${userId}/banners/${guildMemberBanner}.${format}` as const; }, + + /** + * Route for: + * - GET `/soundboard-sounds/${sound.id}` + */ + soundboardSound(soundId: Snowflake) { + return `/soundboard-sounds/${soundId}` as const; + }, }; export type DefaultUserAvatarAssets = 0 | 1 | 2 | 3 | 4 | 5; diff --git a/rest/v10/soundboard.ts b/rest/v10/soundboard.ts new file mode 100644 index 00000000..25d3973d --- /dev/null +++ b/rest/v10/soundboard.ts @@ -0,0 +1,107 @@ +import type { Snowflake } from '../../globals'; +import type { APISoundboardSound } from '../../payloads/v10/index'; + +/** + * https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound + */ +export type RESTPostAPISendSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound-json-params + */ +export interface RESTPostAPISoundboardSendSoundJSONBody { + /** + * The id of the soundboard sound to play + */ + sound_id: Snowflake; + /** + * The id of the guild the soundboard sound is from, required to play sounds from different servers + */ + source_guild_id?: Snowflake | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#list-soundboard-default-sounds + */ +export type RESTGetAPISoundboardDefaultSoundsResult = APISoundboardSound[]; + +/** + * https://discord.com/developers/docs/resources/soundboard#list-guild-soundboard-sounds + */ +export interface RESTGetAPIGuildSoundboardSoundsResult { + items: APISoundboardSound[]; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#get-guild-soundboard-sound + */ +export type RESTGetAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound-json-params + */ +export interface RESTPostAPIGuildSoundboardSoundJSONBody { + /** + * The name of the soundboard sound (2-32 characters) + */ + name: string; + /** + * The data uri of the mp3 or ogg sound data, base64 encoded, similar to image data + * + * See https://discord.com/developers/docs/reference#image-data + */ + sound: string; + /** + * The volume of the soundboard sound, from 0 to 1 + * + * @default 1 + */ + volume?: number | null | undefined; + /** + * The id of the custom emoji for the soundboard sound + */ + emoji_id?: Snowflake | null | undefined; + /** + * The unicode character of a standard emoji for the soundboard sound + */ + emoji_name?: string | null | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound + */ +export type RESTPostAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound-json-params + */ +export interface RESTPatchAPIGuildSoundboardSoundJSONBody { + /** + * The name of the soundboard sound (2-32 characters) + */ + name?: string | undefined; + /** + * The volume of the soundboard sound, from 0 to 1 + * + * @default 1 + */ + volume?: number | null | undefined; + /** + * The id of the custom emoji for the soundboard sound + */ + emoji_id?: Snowflake | null | undefined; + /** + * The unicode character of a standard emoji for the soundboard sound + */ + emoji_name?: string | null | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound + */ +export type RESTPatchAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#delete-guild-soundboard-sound + */ +export type RESTDeleteAPIGuildSoundboardSoundResult = never; diff --git a/rest/v9/index.ts b/rest/v9/index.ts index 648f1ace..53727f2f 100644 --- a/rest/v9/index.ts +++ b/rest/v9/index.ts @@ -11,15 +11,16 @@ export * from './guild'; export * from './guildScheduledEvent'; export * from './interactions'; export * from './invite'; +export * from './monetization'; export * from './oauth2'; export * from './poll'; +export * from './soundboard'; export * from './stageInstance'; export * from './sticker'; export * from './template'; export * from './user'; export * from './voice'; export * from './webhook'; -export * from './monetization'; export const APIVersion = '9'; @@ -1019,11 +1020,46 @@ export const Routes = { /** * Route for: - * - GET `/skus/{sku.id}/subscriptions/${subscription.id}` + * - GET `/skus/{sku.id}/subscriptions/{subscription.id}` */ skuSubscription(skuId: Snowflake, subscriptionId: Snowflake) { return `/skus/${skuId}/subscriptions/${subscriptionId}` as const; }, + + /** + * Route for: + * - POST `/channels/{channel.id}/send-soundboard-sound` + */ + sendSoundboardSound(channelId: Snowflake) { + return `/channels/${channelId}/send-soundboard-sound` as const; + }, + + /** + * Route for: + * - GET `/soundboard-default-sounds` + */ + soundboardDefaultSounds() { + return '/soundboard-default-sounds' as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/soundboard-sounds` + * - POST `/guilds/{guild.id}/soundboard-sounds` + */ + guildSoundboardSounds(guildId: Snowflake) { + return `/guilds/${guildId}/soundboard-sounds` as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + * - PATCH `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + * - DELETE `/guilds/{guild.id}/soundboard-sounds/{sound.id}` + */ + guildSoundboardSound(guildId: Snowflake, soundId: Snowflake) { + return `/guilds/${guildId}/soundboard-sounds/${soundId}` as const; + }, }; export const StickerPackApplicationId = '710982414301790216'; @@ -1313,6 +1349,14 @@ export const CDNRoutes = { ) { return `/guilds/${guildId}/users/${userId}/banners/${guildMemberBanner}.${format}` as const; }, + + /** + * Route for: + * - GET `/soundboard-sounds/${sound.id}` + */ + soundboardSound(soundId: Snowflake) { + return `/soundboard-sounds/${soundId}` as const; + }, }; export type DefaultUserAvatarAssets = 0 | 1 | 2 | 3 | 4 | 5; diff --git a/rest/v9/soundboard.ts b/rest/v9/soundboard.ts new file mode 100644 index 00000000..25d3973d --- /dev/null +++ b/rest/v9/soundboard.ts @@ -0,0 +1,107 @@ +import type { Snowflake } from '../../globals'; +import type { APISoundboardSound } from '../../payloads/v10/index'; + +/** + * https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound + */ +export type RESTPostAPISendSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound-json-params + */ +export interface RESTPostAPISoundboardSendSoundJSONBody { + /** + * The id of the soundboard sound to play + */ + sound_id: Snowflake; + /** + * The id of the guild the soundboard sound is from, required to play sounds from different servers + */ + source_guild_id?: Snowflake | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#list-soundboard-default-sounds + */ +export type RESTGetAPISoundboardDefaultSoundsResult = APISoundboardSound[]; + +/** + * https://discord.com/developers/docs/resources/soundboard#list-guild-soundboard-sounds + */ +export interface RESTGetAPIGuildSoundboardSoundsResult { + items: APISoundboardSound[]; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#get-guild-soundboard-sound + */ +export type RESTGetAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound-json-params + */ +export interface RESTPostAPIGuildSoundboardSoundJSONBody { + /** + * The name of the soundboard sound (2-32 characters) + */ + name: string; + /** + * The data uri of the mp3 or ogg sound data, base64 encoded, similar to image data + * + * See https://discord.com/developers/docs/reference#image-data + */ + sound: string; + /** + * The volume of the soundboard sound, from 0 to 1 + * + * @default 1 + */ + volume?: number | null | undefined; + /** + * The id of the custom emoji for the soundboard sound + */ + emoji_id?: Snowflake | null | undefined; + /** + * The unicode character of a standard emoji for the soundboard sound + */ + emoji_name?: string | null | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound + */ +export type RESTPostAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound-json-params + */ +export interface RESTPatchAPIGuildSoundboardSoundJSONBody { + /** + * The name of the soundboard sound (2-32 characters) + */ + name?: string | undefined; + /** + * The volume of the soundboard sound, from 0 to 1 + * + * @default 1 + */ + volume?: number | null | undefined; + /** + * The id of the custom emoji for the soundboard sound + */ + emoji_id?: Snowflake | null | undefined; + /** + * The unicode character of a standard emoji for the soundboard sound + */ + emoji_name?: string | null | undefined; +} + +/** + * https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound + */ +export type RESTPatchAPIGuildSoundboardSoundResult = APISoundboardSound; + +/** + * https://discord.com/developers/docs/resources/soundboard#delete-guild-soundboard-sound + */ +export type RESTDeleteAPIGuildSoundboardSoundResult = never;