-
-
Notifications
You must be signed in to change notification settings - Fork 102
Custom Commands
job-gut edited this page Feb 8, 2023
·
6 revisions
import { command } from "bdsx/command";
import { CommandRawText } from "bdsx/bds/command";
command.register('echo', 'repeat text').overload((param, origin, output)=>{
console.log(param.rawtext.text);
}, { rawtext:CommandRawText });
import { command } from "bdsx/command";
import { CommandRawText } from "bdsx/bds/command";
command.register('echo', 'repeat text', CommandPermissionLevel.Operator).overload((param, origin, output) => { //makes it so only people with Operator can use and see the command
console.log(param.rawtext.text);
}, { rawtext:CommandRawText });
import { events } from "bdsx/event";
events.command.on((cmd, origin, ctx)=>{
switch (cmd) {
case 'whoami':
if (ctx.origin.isServerCommandOrigin()) {
console.log('You are the server console');
} else {
console.log('You are '+origin);
}
break;
default: return; // process the default command
}
return 0; // suppress the command, It will mute 'Unknown command' message.
});