/beep or /ding

578ef7eb6c6ed393024dff14eef07abbae9d9d5b

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +22 -4Ignore whitespace
public/scripts/power-user.js+10 -3
@@ -380,12 +380,19 @@ const debug_functions = [];
380380
381381const setHotswapsDebounced = debounce(favsToHotswap);
382382
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) {
385392 return;
386393 }
387394
388395 if (power_user.play_sound_unfocused && browser_has_focus && !force) {
389396 return;
390397 }
391398
public/scripts/slash-commands.js+12 -1
@@ -65,7 +65,7 @@ import { getRegexedString, regex_placement } from './extensions/regex/engine.js'
6565import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group, getGroupMembers } from './group-chats.js';
6666import { chat_completion_sources, oai_settings, promptManager, ZAI_ENDPOINT } from './openai.js';
6767import { user_avatar } from './personas.js';
6868import { addEphemeralStoppingString, chat_styles, context_presets, flushEphemeralStoppingStrings, playMessageSound, power_user } from './power-user.js';
6969import { SERVER_INPUTS, textgen_types, textgenerationwebui_settings } from './textgen-settings.js';
7070import { decodeTextTokens, getAvailableTokenizers, getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, selectTokenizer } from './tokenizers.js';
7171import { debounce, delay, equalsIgnoreCaseAndAccents, findChar, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, regexFromString, showFontAwesomePicker, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
@@ -3145,6 +3145,17 @@ export function initDefaultSlashCommands() {
31453145 `,
31463146 }));
31473147
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+
31483159 registerVariableCommands();
31493160}
31503161