/beep or /ding
| @@ -380,12 +380,19 @@ const debug_functions = []; | ||
| 380 | 380 | |
| 381 | 381 | const setHotswapsDebounced = debounce(favsToHotswap); |
| 382 | 382 | |
| 383 | -export function playMessageSound() { | |
| 383 | +/** | |
| 384 | - if (!power_user.play_message_sound) { | |
| 384 | + * Plays the message sound if enabled in power user settings. | |
| 385 | + * Passes through the `force` parameter to override settings. | |
| 386 | + * @param {object} [param] Arguments object. | |
| 387 | + * @param {boolean} [param.force] Whether to force play the sound. | |
| 388 | + * @returns {void} | |
| 389 | + */ | |
| 390 | +export function playMessageSound({ force } = {}) { | |
| 391 | + if (!power_user.play_message_sound && !force) { | |
| 385 | 392 | return; |
| 386 | 393 | } |
| 387 | 394 | |
| 388 | 395 | if (power_user.play_sound_unfocused && browser_has_focus && !force) { |
| 389 | 396 | return; |
| 390 | 397 | } |
| 391 | 398 | |
| @@ -65,7 +65,7 @@ import { getRegexedString, regex_placement } from './extensions/regex/engine.js' | ||
| 65 | 65 | import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group, getGroupMembers } from './group-chats.js'; |
| 66 | 66 | import { chat_completion_sources, oai_settings, promptManager, ZAI_ENDPOINT } from './openai.js'; |
| 67 | 67 | import { user_avatar } from './personas.js'; |
| 68 | 68 | import { addEphemeralStoppingString, chat_styles, context_presets, flushEphemeralStoppingStrings, playMessageSound, power_user } from './power-user.js'; |
| 69 | 69 | import { SERVER_INPUTS, textgen_types, textgenerationwebui_settings } from './textgen-settings.js'; |
| 70 | 70 | import { decodeTextTokens, getAvailableTokenizers, getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, selectTokenizer } from './tokenizers.js'; |
| 71 | 71 | import { debounce, delay, equalsIgnoreCaseAndAccents, findChar, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, regexFromString, showFontAwesomePicker, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js'; |
| @@ -3145,6 +3145,17 @@ export function initDefaultSlashCommands() { | ||
| 3145 | 3145 | `, |
| 3146 | 3146 | })); |
| 3147 | 3147 | |
| 3148 | + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |
| 3149 | + name: 'beep', | |
| 3150 | + aliases: ['ding'], | |
| 3151 | + returns: t`an empty string`, | |
| 3152 | + callback: async () => { | |
| 3153 | + playMessageSound({ force: true }); | |
| 3154 | + return ''; | |
| 3155 | + }, | |
| 3156 | + helpString: t`Plays the message received sound effect.`, | |
| 3157 | + })); | |
| 3158 | + | |
| 3148 | 3159 | registerVariableCommands(); |
| 3149 | 3160 | } |
| 3150 | 3161 | |