Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Command Pallete Test */
/**
* This is an example for implementing the command through mw.hook(),
* for places like MediaWiki:Citizen.js or gadgets.
*
* If you are implementing a built-in command, please refer to other
* non-example files in this directory.
*
* Note that site scripts and gadgets might not support Modern JS syntax (T381537, T389736).
*/
/* eslint-disable no-console */
/* Type declaration is not required, but is included for clarity. */
const { CommandPaletteCommand, CommandPaletteItem, CommandPaletteActionResult } = require( '../types.js' );
/**
* Example Simple Command
*
* This demonstrates registering a simple command without a sub-query.
* It performs an action directly when selected.
*
* @type {CommandPaletteCommand}
*/
const exampleSimpleCommand = {
/**
* Unique identifier for this command.
*/
id: 'join-game',
/**
* Triggers: Keywords that activate this command.
* Should not end with a colon as there's no sub-query.
*/
triggers: [ '/join', '/play' ],
/**
* Label: The display name of the command in the initial command list.
*/
label: 'Join the game',
/**
* Description: A short explanation shown below the label.
*/
description: 'Places you into a random server in game.',
/**
* onCommandSelect: Handles selection of the command item itself.
* Since there's no sub-query, this performs the final action.
*
* @param {CommandPaletteItem} item The selected command item.
* @return {CommandPaletteActionResult} Action result for the UI.
*/
onCommandSelect( item ) {
console.debug( '[ExampleSimpleCommand] Command selected:', item );
window.open('roblox://12018816388', '_blank');
// Close the palette after execution
return { action: 'close' };
},
// No getResults or onResultSelect needed for a simple command.
type: 'command-example-simple' // Add a specific type if needed
};
// Register the command
mw.loader.using( 'skins.citizen.commandPalette' ).then( () => {
mw.hook( 'skins.citizen.commandPalette.registerCommand' ).add( ( registrationData ) => {
if ( registrationData && registrationData.registerCommand ) {
registrationData.registerCommand( exampleSimpleCommand );
}
} );
} );