schat2-clive/src/games/kill.js

39 lines
1.3 KiB
JavaScript
Executable File

'use strict';
const config = require('config');
const style = require('../utils/style');
function onCommand(args, context) {
if (config.platform === 'schat') {
Object.keys(context.bot.rooms).forEach((roomId) => {
context.sendMessage(`Kill command used by ${style.bold(context.user.username)}, shutting down... :sleeping:`, roomId, { type: 'message', label: false });
});
if (context.message.user) {
context.sendMessage('Shutting down... :sleeping:', context.room?.id, { type: 'message', label: false }, context.message.user.username);
}
}
if (config.platform === 'irc') {
context.bot.rooms.forEach((room) => {
context.sendMessage(`Kill command used by ${style.bold(context.user.username)}, shutting down... 😴`, room.id, { type: 'message', label: false });
});
if (context.room.id === config.user.id) {
// if the room ID is the bot's own nickname, it's a PM and we should reply to the sender
context.sendMessage('Shutting down... 😴', context.user.id, { type: 'message', label: false }, context.message.user.username);
}
}
context.logger.info(`Kill command used by ${context.user.username}`);
setTimeout(() => process.exit(), 1000);
}
module.exports = {
commands: ['kill', 'restart', 'shutdown'],
help: `Am I getting a little confused? Try to ${config.prefix}restart me.`,
onCommand,
};