How to make a command like
If i entered "!cboutput" the gamerule will turn false,and if i do it again,it will turn true,or depends on world's gamerule
import { world } from '@minecraft/server';
world.events.beforeChat.subscribe(async (eventData) => {
const player = eventData.sender;
if (!player.hasTag('Admin')) return;
switch (eventData.message) {
case '!help':
eventData.cancel = true;
await player.runCommandAsync('tellraw @p {"rawtext":[{"text":"§l×××××××××××××××××××××××××××§r\n§lAdmin commands§r\n§7Prefix *§f!§7*§r\n\nhelp §7- show lists of cmds§r\ngms §7- survival mode§r\ngmc §7- creative mode§r\nspec §7- spectator mode§r\ncb §7- command block§r\ncboutput §7- disable commandblock output§r\nc §7- clear inventory§r\n§l××××××××××××××××××××××××××××"}]}');
break;
case '!gmc':
eventData.cancel = true;
await player.runCommandAsync('gamemode c');
break;
case '!gms':
eventData.cancel = true;
await player.runCommandAsync('gamemode s');
break;
case '!cb':
eventData.cancel = true;
await player.runCommandAsync('give @p command_block');
break;
case '!spec':
eventData.cancel = true;
await player.runCommandAsync('gamemode spectator');
break;
case '!cboutput':
eventData.cancel = true;
await player.runCommandAsync('gamerule commandblockoutput false');
break;
case '!c':
eventData.cancel = true;
await player.runCommandAsync('clear @p');
break;
default: break;
}
});