Files
discord-decomp/modules/soundboard/BaseSoundboardManager.tsx
T
2026-11-01 12:12:55 +02:00

37 lines
1.7 KiB
TypeScript

// Metro module 13593 (f13594).
import AuthenticationStore from "../../stores/AuthenticationStore";
import MediaEngineStore from "../../stores/MediaEngineStore";
import LifecycleManager from "../../lib/LifecycleManager";
import Dispatcher from "../../Dispatcher";
class BaseSoundboardManager extends LifecycleManager {
_playSound = () => {};
_stopAndClearSounds = () => {};
_handleToggleSelfDeafened = () => {
if (MediaEngineStore.isDeaf()) {
this._stopAndClearSounds();
}
};
_handleSoundboardSoundReceived = ({ soundId, soundVolume, userId, channelId }) => {
if (soundId != null && userId !== AuthenticationStore.getId()) {
return this._playSound(soundId, soundVolume, userId, channelId);
}
};
_handleSoundboardSoundPlayLocally = ({ sound, channelId }) => this._playSound(sound.soundId, sound.volume, AuthenticationStore.getId(), channelId);
_handleVoiceChannelSelect = () => {
this._stopAndClearSounds();
};
_initialize() {
Dispatcher.subscribe("VOICE_CHANNEL_EFFECT_SEND", this._handleSoundboardSoundReceived);
Dispatcher.subscribe("GUILD_SOUNDBOARD_SOUND_PLAY_LOCALLY", this._handleSoundboardSoundPlayLocally);
Dispatcher.subscribe("VOICE_CHANNEL_SELECT", this._handleVoiceChannelSelect);
Dispatcher.subscribe("AUDIO_TOGGLE_SELF_DEAF", this._handleToggleSelfDeafened);
}
_terminate() {
Dispatcher.unsubscribe("VOICE_CHANNEL_EFFECT_SEND", this._handleSoundboardSoundReceived);
Dispatcher.unsubscribe("GUILD_SOUNDBOARD_SOUND_PLAY_LOCALLY", this._handleSoundboardSoundPlayLocally);
Dispatcher.unsubscribe("VOICE_CHANNEL_SELECT", this._handleVoiceChannelSelect);
Dispatcher.unsubscribe("AUDIO_TOGGLE_SELF_DEAF", this._handleToggleSelfDeafened);
}
}
export default BaseSoundboardManager;