About command

i have a command:
api.executeCommand(‘overwriteConfig’, {
toolbarButtons: [‘chat’]
});
when i install in file index.html like this:
const domain = ‘myjitsi1.com’; // change domain to match your Jitsi server
const options = {
roomName: ‘Class 111’,
configOverwrite: {
startWithAudioMuted: true
},
parentNode: document.querySelector(‘#meet’),
};
const api = new JitsiMeetExternalAPI(domain, options);

    api.addEventListener('participantRoleChanged', function (event) {
        if (event.role === 'moderator') {
            console.log('moderator is you');
            api.executeCommand('overwriteConfig', {
                toolbarButtons: ['chat']
            });

        } else {
            console.log('moderator is not you');

        }
    });

But it not work. Some one help me? Thank you. Other different commands still work.

Does not work how?

It seems to work as expected when I tried it here: JSFiddle . You’ll see that the toolbar changes to just the “chat” icon shortly after joining (because by default in meet.jit.si joins everyone gets promoted to moderator).

It dont override toolbarbuttons.You can see it.

As you can see in my JSFiddle above, it does. Try it.

Any errors in JS console?

It show errors like your page

I don’t understand. What error in my page?


my console like this.

No idea what that error is, but looks like the command works? I see that the toolbar has changed in your screenshot.

It is your web not mine

Try clearing your browser’s cache or testing in incognito (private mode) on your browser.

i try it but it not work

Sorry, I was not very clear. The point I was trying to make was the the command itself works because we can see it working in the JSFiddle example.

Which means that if it doesn’t work for you, the issue would be with your client code or setup.

We’ll need to try and narrow down where the problem is. Personally, first thing I would do is figure out if your problem is that the overwriteConfig command is not working for you, or if participantRoleChanged is not triggerring as expected. Perhaps try the following:

  1. Log out event in the participantRoleChanged event listener.
  2. Run the command under a different listener, e.g. videoConferenceJoined

So something like this:

api.addEventListener('participantRoleChanged', function (event) {
    console.log("role changed", event);
})

api.addEventListener('videoConferenceJoined', function (event) {
    api.executeCommand('overwriteConfig', {
        toolbarButtons: ['chat']
    });
})

You’d expect to see “role changed” being logged out with the expected event.role value, and you’d expect the toolbar to change. If either one does not happen, then we know where to focus the debugging on. And if they both work, then it is down you have put them together in your client code.


participantRoleChanged` is not triggerring as expected