For that additional functionality you can check for the subwindows.
Below is edited code. I changed the structure a bit to make it cleaner. So replace the old with this new one and change the sound effects to what you want. (edit: don't change where it says SE, just the 3 names in quote marks)
Below is edited code. I changed the structure a bit to make it cleaner. So replace the old with this new one and change the sound effects to what you want. (edit: don't change where it says SE, just the 3 names in quote marks)
const _myEdit1_WindowMessage_newPage = Window_Message.prototype.newPage;Window_Message.prototype.newPage = function(textState) { _myEdit1_WindowMessage_newPage.call(this, textState); if (this.isClosed()) { if ($gameMessage.background() !== 2) { this.playOpenCloseContinueSE('Bell1'); } } else { if (!this.isAnySubWindowClosing()) { this.playOpenCloseContinueSE('Buzzer1'); } } };const _myEdit1_WindowMessage_update = Window_Message.prototype.update;Window_Message.prototype.update = function() { if (this.isOpen() && this.isClosing() && !this.doesContinue() && this._background !== 2) { this.playOpenCloseContinueSE('Cow'); } _myEdit1_WindowMessage_update.call(this);};Window_Message.prototype.playOpenCloseContinueSE = function(SE) { AudioManager.playSe({ name: SE, volume: 100, pitch: 100, pan: 0 });};Window_Message.prototype.isAnySubWindowClosing = function() { return ( this._choiceListWindow?.isClosing() || this._numberInputWindow?.isClosing() || this._eventItemWindow?.isClosing() );};