-
-
Notifications
You must be signed in to change notification settings - Fork 4k
feat: add soundboard #10590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: add soundboard #10590
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b61e513
feat: add soundboard
sdanialraza 3fd1de9
Merge branch 'main' into feat/add-soundboard
sdanialraza eb35baf
types(PartialSoundboardSound): add `available`
sdanialraza 0c690d9
Merge branch 'main' into feat/add-soundboard
sdanialraza 3468244
feat(VoiceChannelEffect): add `soundboardSound` getter
sdanialraza 1a27c98
types: improve return types
sdanialraza bc4da39
docs: requested changes
sdanialraza 939905b
feat: support multiple audio file types
sdanialraza 20499f5
types(GuildSoundboardSoundCreateOptions): add `contentType`
sdanialraza 2bf1f1a
types: add default and guild soundboard sound
sdanialraza 71e2e28
fix: requested changes
sdanialraza ff64ad3
Merge branch 'main' into feat/add-soundboard
sdanialraza 74f190e
docs: use `@fires` tag
sdanialraza 9a301c9
docs: remove misleading tag
sdanialraza 02d2783
Merge branch 'main' into feat/add-soundboard
sdanialraza 0788bdc
Merge branch 'main' into feat/add-soundboard
sdanialraza 7b3cfe4
chore: requested changes and missing things
sdanialraza 6bf70b5
Merge branch 'main' into feat/add-soundboard
sdanialraza 77b2f36
feat: add send soundboard sound options
sdanialraza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/discord.js/src/client/actions/GuildSoundboardSoundDelete.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const { Action } = require('./Action.js'); | ||
const { Events } = require('../../util/Events.js'); | ||
|
||
class GuildSoundboardSoundDeleteAction extends Action { | ||
Qjuh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
handle(data) { | ||
const guild = this.client.guilds.cache.get(data.guild_id); | ||
|
||
if (!guild) return {}; | ||
|
||
const soundboardSound = this.getSoundboardSound(data, guild); | ||
|
||
if (soundboardSound) { | ||
guild.soundboardSounds.cache.delete(soundboardSound.soundId); | ||
|
||
/** | ||
* Emitted whenever a soundboard sound is deleted in a guild. | ||
* @event Client#guildSoundboardSoundDelete | ||
* @param {SoundboardSound} soundboardSound The soundboard sound that was deleted | ||
*/ | ||
this.client.emit(Events.GuildSoundboardSoundDelete, soundboardSound); | ||
} | ||
|
||
return { soundboardSound }; | ||
} | ||
} | ||
|
||
exports.GuildSoundboardSoundDeleteAction = GuildSoundboardSoundDeleteAction; |
24 changes: 24 additions & 0 deletions
24
packages/discord.js/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const { Collection } = require('@discordjs/collection'); | ||
const { Events } = require('../../../util/Events.js'); | ||
|
||
module.exports = (client, { d: data }) => { | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (!guild) return; | ||
|
||
const soundboardSounds = new Collection(); | ||
|
||
for (const soundboardSound of data.soundboard_sounds) { | ||
soundboardSounds.set(soundboardSound.sound_id, guild.soundboardSounds._add(soundboardSound)); | ||
} | ||
|
||
/** | ||
* Emitted whenever multiple guild soundboard sounds are updated. | ||
* @event Client#guildSoundboardSoundsUpdate | ||
* @param {Collection<Snowflake, SoundboardSound>} soundboardSounds The updated soundboard sounds | ||
* @param {Guild} guild The guild that the soundboard sounds are from | ||
*/ | ||
client.emit(Events.GuildSoundboardSoundsUpdate, soundboardSounds, guild); | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/discord.js/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const { Events } = require('../../../util/Events.js'); | ||
|
||
module.exports = (client, { d: data }) => { | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (!guild) return; | ||
|
||
const soundboardSound = guild.soundboardSounds._add(data); | ||
|
||
/** | ||
* Emitted whenever a guild soundboard sound is created. | ||
* @event Client#guildSoundboardSoundCreate | ||
* @param {SoundboardSound} soundboardSound The created guild soundboard sound | ||
*/ | ||
client.emit(Events.GuildSoundboardSoundCreate, soundboardSound); | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/discord.js/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, { d: data }) => { | ||
client.actions.GuildSoundboardSoundDelete.handle(data); | ||
}; |
20 changes: 20 additions & 0 deletions
20
packages/discord.js/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
const { Events } = require('../../../util/Events.js'); | ||
|
||
module.exports = (client, { d: data }) => { | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (!guild) return; | ||
|
||
const oldGuildSoundboardSound = guild.soundboardSounds.cache.get(data.sound_id)?._clone() ?? null; | ||
const newGuildSoundboardSound = guild.soundboardSounds._add(data); | ||
|
||
/** | ||
* Emitted whenever a guild soundboard sound is updated. | ||
* @event Client#guildSoundboardSoundUpdate | ||
* @param {?SoundboardSound} oldGuildSoundboardSound The guild soundboard sound before the update | ||
* @param {SoundboardSound} newGuildSoundboardSound The guild soundboard sound after the update | ||
*/ | ||
client.emit(Events.GuildSoundboardSoundUpdate, oldGuildSoundboardSound, newGuildSoundboardSound); | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/discord.js/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const { Collection } = require('@discordjs/collection'); | ||
const { Events } = require('../../../util/Events.js'); | ||
|
||
module.exports = (client, { d: data }) => { | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (!guild) return; | ||
|
||
const soundboardSounds = new Collection(); | ||
|
||
for (const soundboardSound of data.soundboard_sounds) { | ||
soundboardSounds.set(soundboardSound.sound_id, guild.soundboardSounds._add(soundboardSound)); | ||
} | ||
|
||
/** | ||
* Emitted whenever soundboard sounds are received (all soundboard sounds come from the same guild). | ||
* @event Client#soundboardSounds | ||
* @param {Collection<Snowflake, SoundboardSound>} soundboardSounds The sounds received | ||
* @param {Guild} guild The guild that the soundboard sounds are from | ||
*/ | ||
client.emit(Events.SoundboardSounds, soundboardSounds, guild); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.