// Module ID: 5959 // Function ID: 5960 // Name: hasPermissionToPlaySound // Dependencies: [5, 1340, 1376, 3929, 1903, 4749, 4750, 676, 1338, 3974, 3947, 5960, 5953, 4756, 5961, 709, 5988, 5989, 5990, 647, 4146, 1358, 1355, 698, 4498, 2] // Exports: getAmplitudinalSoundboardVolume, hasSetAnyCustomJoinSound, maybePlayCustomJoinSound, playSound, removeCustomJoinSound, trackCustomCallSoundExternallyDeleted, trackSoundFavorited, updateCustomJoinSound, useSoundBoardDismissContentTypes // Module 5959 (hasPermissionToPlaySound) import handleSoundCreateOrUpdate from "handleSoundCreateOrUpdate"; import handleConnectionClosedOrResumed from "handleConnectionClosedOrResumed"; import { SILENT_JOIN_LEAVE_CHANNEL_TYPES as closure_5 } from "createChannelRecord"; import getUncachedChannelPermissions from "getUncachedChannelPermissions"; import mergeGuildAvatar from "mergeGuildAvatar"; import closure_8 from "handleSoundCreateOrUpdate"; import MAX_LENGTH_SOUND_NAME from "MAX_LENGTH_SOUND_NAME"; import ME from "ME"; import { ExpressionPickerViewType } from "ExpressionPickerViewType"; let c10; let c9; let closure_12; let unpackModuleId; const require = arg1; function hasPermissionToPlaySound(guildId, guild_id) { guild_id = undefined; if (guild_id != null) { guild_id = guild_id.guild_id; } let canResult = null == guild_id; if (!canResult) { canResult = getUncachedChannelPermissions.can(constants.USE_EXTERNAL_SOUNDS, guild_id); } if (!canResult) { canResult = guildId.guildId === closure_10; } if (!canResult) { let guild_id1; if (guild_id != null) { guild_id1 = guild_id.guild_id; } canResult = guildId.guildId === guild_id1; } return canResult; } function canUseSoundboardSound(closure_0, closure_1, channel) { let flag = arg3; if (arg3 === undefined) { flag = true; } let result = importDefault(3947).canUseSoundboardEverywhere(closure_0); if (!result) { let guild_id; if (channel != null) { guild_id = channel.guild_id; } result = closure_1.guildId === guild_id; } if (!result) { result = closure_1.guildId === closure_10; } if (result) { let guild_id1; if (channel != null) { guild_id1 = channel.guild_id; } let canResult = null == guild_id1; if (!canResult) { canResult = getUncachedChannelPermissions.can(constants.USE_EXTERNAL_SOUNDS, channel); } if (!canResult) { canResult = closure_1.guildId === closure_10; } if (!canResult) { let guild_id2; if (channel != null) { guild_id2 = channel.guild_id; } canResult = closure_1.guildId === guild_id2; } result = canResult; } if (result) { let available = !flag; if (flag) { available = closure_1.available; } result = available; } return result; } function canMakeSound(channel) { let obj = require(5960) /* getMuteStates */; obj = { channel }; const muteStates = obj.getMuteStates(obj); const mute = muteStates.mute; let tmp2 = !mute; if (!mute) { tmp2 = !muteStates.suppress; } return tmp2; } function _maybePlayCustomJoinSound() { const self = this; const tmp = callback((arg0) => { let closure_0 = arg0; let c3 = 0; let c4 = 0; return (function*(arg0) { if (sound2 === 2) { sound2 = 3; HermesBuiltin.throwTypeError(); } else if (tmp5 === 3) { if (arg0 === 1) { throw arg1; } else if (arg0 === 2) { let obj = { value: null, done: true }; obj[0] = arg1; return obj; } else { return { value: "HermesInternal", done: null }; } } else { try { sound2 = 2; if (0 === guildId) { if (arg0 === 1) { sound2 = 3; throw arg1; } else if (arg0 === 2) { sound2 = 3; obj = { value: null, done: true }; obj[0] = arg1; return obj; } else { let customJoinSound = tmp3; let id = tmp2; let currentUser; id = undefined; customJoinSound = undefined; guildId = undefined; sound2 = undefined; currentUser = outer1_7.getCurrentUser(); const tmp53 = outer1_1(outer1_2[16])(); id = tmp53; customJoinSound = callback(outer1_2[17]).getCustomJoinSound(currentUser); if (null != tmp53) { if (!outer1_5.has(tmp53.type)) { if (null != customJoinSound) { if (tmp51Result.canUseCustomCallSounds(currentUser)) { let tmp54Result = tmp54(tmp52[18]); if (tmp54Result.canSelectedVoiceChannelUseSoundboard()) { tmp54Result = tmp54(tmp52[12]); guildId = 1; sound2 = 1; const obj1 = { value: null, done: false }; obj1[0] = tmp54Result.maybeFetchSoundboardSounds(); return obj1; } } tmp51Result = tmp51(tmp52[10]); } } } const obj9 = callback(outer1_2[17]); tmp51 = outer1_1; } } else if (arg0 === 1) { sound2 = 3; throw arg1; } else if (arg0 === 2) { sound2 = 3; const obj2 = { value: null, done: true }; obj2[0] = arg1; return obj2; } else { if (customJoinSound.guildId === closure_9) { guildId = closure_10; } else { guildId = customJoinSound.guildId; } sound2 = sound.getSound(guildId, customJoinSound.soundId); if (null != sound2) { let tmp23 = null; if (callback2(sound2, id)) { tmp23 = null; if (callback3(currentUser, sound2, id, true)) { tmp23 = null; if (callback4(id)) { (function playCustomJoinSound(c4, id) { currentUser(customJoinSound[12]).playSoundLocally(id, c4, currentUser(customJoinSound[13]).LocalSoundTrigger.JOINED_VOICE_CHANNEL); const obj = currentUser(customJoinSound[12]); const result = currentUser(customJoinSound[14]).sendVoiceChannelCustomCallSoundEffect(id, c4, false); })(sound2, id.id); } } } sound2 = 3; obj = { value: null, done: true }; obj[0] = tmp23; return obj; } } sound2 = 3; return { value: "HermesInternal", done: null }; } catch (tmp33) { sound2 = tmp; throw tmp33; } } })(); }); const _maybePlayCustomJoinSound = tmp; const apply = tmp.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; } ({ CUSTOM_CALL_SOUND_GLOBAL_GUILD_ID: c9, DEFAULT_SOUND_GUILD_ID: c10 } = MAX_LENGTH_SOUND_NAME); ({ Permissions: unpackModuleId, AnalyticEvents: closure_12 } = ME); let result = require("createChannelRecord").fileFinishedImporting("modules/soundboard/SoundboardUtils.tsx"); export const getAmplitudinalSoundboardVolume = function getAmplitudinalSoundboardVolume() { const SoundboardSettings = require(3974) /* explicitContentFromProto */.SoundboardSettings; const setting = SoundboardSettings.getSetting(); let num; if (setting != null) { num = setting.volume; } if (num == null) { num = 100; } return num; }; export { hasPermissionToPlaySound }; export { canUseSoundboardSound }; export { canMakeSound }; export const playSound = function playSound(soundId, channelId) { let obj = require(5953) /* _fetchDefaultSoundsFromApi2 */; obj.playSoundLocally(channelId, soundId, require(4756) /* SoundButtonOverlay */.LocalSoundTrigger.SOUNDBOARD); const result = require(5961) /* VoiceChannelEffectSentLocation */.sendVoiceChannelSoundboardEffect(channelId, soundId, false, arg2, arg3); const obj2 = require(5961) /* VoiceChannelEffectSentLocation */; obj = { type: "SOUNDBOARD_TRACK_USAGE", soundId: soundId.soundId }; importDefault(709).dispatch(obj); }; export const hasSetAnyCustomJoinSound = function hasSetAnyCustomJoinSound() { let guilds = handleConnectionClosedOrResumed.settings.guilds; guilds = undefined; if (guilds != null) { guilds = guilds.guilds; } if (guilds == null) { guilds = {}; } const values = Object.values(guilds); return values.some((joinSound) => null != joinSound.joinSound); }; export const maybePlayCustomJoinSound = function maybePlayCustomJoinSound() { const self = this; const apply = _maybePlayCustomJoinSound.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; }; export const useSoundBoardDismissContentTypes = function useSoundBoardDismissContentTypes(isSoundboardButtonDisabled) { let flag = isSoundboardButtonDisabled.isSoundboardButtonDisabled; if (flag === undefined) { flag = false; } const items = [mergeGuildAvatar]; const stateFromStores = require(647) /* defaultAreStatesEqual */.useStateFromStores(items, () => currentUser.getCurrentUser()); const items1 = []; if (!flag) { let guilds = handleConnectionClosedOrResumed.settings.guilds; guilds = undefined; if (guilds != null) { guilds = guilds.guilds; } if (guilds == null) { guilds = {}; } const _Object = Object; const values = Object.values(guilds); if (!values.some((joinSound) => null != joinSound.joinSound)) { const result = tmp(4146).ageEligibleForPremiumUpsell(stateFromStores); const tmpResult = tmp(4146); const obj5 = importDefault(3947); if (tmp9) { items1.push(tmp(1358).DismissibleContent.CUSTOM_CALL_SOUNDS_PICKER_UPSELL); } tmp9 = importDefault(3947).canUseCustomCallSounds(stateFromStores) || result; } } return items1; }; export const removeCustomJoinSound = function removeCustomJoinSound(closure_0) { const _require = closure_0; let closure_1 = arg1; const result = _require(1355).updateUserGuildSettings(closure_0, (arg0) => { let _location; let changeType; let soundSource; let soundType; arg0.joinSound = undefined; let obj = { guildId: callback, changeType: callback(outer1_2[13]).AnalyticsChangeType.REMOVED, soundType: callback(outer1_2[13]).AnalyticsSoundType.ENTRY, location: callback2 }; const guildId = obj.guildId; ({ changeType, soundType, soundSource, location: _location } = obj); obj = { location_stack: _location, guild_id: null, change_type: null, sound_type: null, sound_source: null }; let num = 0; if ("" !== guildId) { const _Number = Number; num = Number(guildId); } obj[1] = num; obj[2] = changeType; obj[3] = soundType; obj[4] = soundSource; callback2(outer1_2[23]).track(outer1_12.USER_CUSTOM_CALL_SOUND_SETTING_UPDATED, obj); }, _require(1355).UserSettingsDelay.INFREQUENT_USER_ACTION); }; export const updateCustomJoinSound = function updateCustomJoinSound(closure_0) { const _require = closure_0; let closure_1 = arg1; const dependencyMap = arg2; const result = _require(1355).updateUserGuildSettings(closure_0, (joinSound) => { const AnalyticsSoundSource = callback(table[13]).AnalyticsSoundSource; if (lib.guildId === outer1_10) { let CUSTOM = AnalyticsSoundSource.DEFAULT; let tmp5 = tmp4; let tmp6 = tmp3; } else { CUSTOM = AnalyticsSoundSource.CUSTOM; tmp5 = tmp4; tmp6 = tmp3; } if (null != joinSound.joinSound) { let ADDED = tmp6(tmp5[13]).AnalyticsChangeType.UPDATED; } else { ADDED = tmp6(tmp5[13]).AnalyticsChangeType.ADDED; } joinSound.joinSound = { soundId: lib.soundId, guildId: lib.guildId === outer1_10 ? outer1_9 : lib.guildId }; let obj = lib(tmp5[23]); obj = { location_stack: table, guild_id: null, change_type: null, sound_type: null, sound_source: null }; let num = 0; if ("" !== callback) { const _Number = Number; num = Number(callback); } obj[1] = num; obj[2] = ADDED; obj[3] = tmp6(tmp5[13]).AnalyticsSoundType.ENTRY; obj[4] = CUSTOM; obj.track(outer1_12.USER_CUSTOM_CALL_SOUND_SETTING_UPDATED, obj); }, _require(1355).UserSettingsDelay.INFREQUENT_USER_ACTION); }; export const trackCustomCallSoundExternallyDeleted = function trackCustomCallSoundExternallyDeleted(location_stack) { importDefault(698).track(constants2.USER_CUSTOM_CALL_SOUND_SETTING_GUILD_REMOVED, { location_stack: location_stack.location }); }; export const trackSoundFavorited = function trackSoundFavorited(location) { const sound = location.sound; let obj = importDefault(4498); obj = { location: location.location, expression_type: ExpressionPickerViewType.SOUNDBOARD, expression_id: sound.soundId, expression_name: sound.name, expression_guild_id: sound.guildId }; obj.trackWithMetadata(constants2.EXPRESSION_FAVORITED, obj); };