const logger = require('../../lib/logger');
const IHLCommand = require('../../lib/ihlCommand');
const Dota2 = require('dota2');
const CONSTANTS = require('../../lib/constants');
/**
* @class LobbyGameModeCommand
* @category Commands
* @extends IHLCommand
* @memberof module:ihlCommand
*/
module.exports = class LobbyGameModeCommand extends IHLCommand {
constructor(client) {
super(client, {
name: 'lobby-gamemode',
group: 'admin',
memberName: 'lobby-gamemode',
guildOnly: true,
description: 'Set lobby game mode.',
examples: ['lobby-gamemode cm', 'lobby-gamemode cd', 'lobby-gamemode ap'],
args: [
{
key: 'mode',
prompt: 'Provide a game mode (cm/cd/ap).',
type: 'string',
validate: (mode) => {
if (mode === 'cm' || mode === 'cd' || mode === 'ap') return true;
return 'Value must be cm, cd, or ap';
},
},
],
}, {
inhouseAdmin: true,
inhouseState: true,
lobbyState: true,
inhouseUser: false,
});
}
async onMsg({ msg, lobbyState }, { mode }) {
let gameMode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_CM;
let name = "Captain's Mode";
if (mode === 'cd') {
gameMode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_CD;
name = "Captain's Draft";
}
else if (mode === 'ap') {
gameMode = Dota2.schema.DOTA_GameMode.DOTA_GAMEMODE_AP;
name = 'All Pick';
}
const result = await this.ihlManager[CONSTANTS.EVENT_LOBBY_SET_GAMEMODE](lobbyState, gameMode);
return msg.say(result ? `Game mode set to ${name}.` : 'Failed to set game mode.');
}
};
Source