39 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2025-03-16 15:02:23 +01:00
const scenarios = require('../scenario/scenario.js');
const _ = require('underscore');
const helptext = `The \`!scenario\` command can be used to select a scenario to play. use \`!scenario\` to list all options, and \`!scenario <name>\` to select a particular scenario.`;
function s(context) {
return new Promise((resolve, reject) => {
if(context.isHelpRequest) {
context.message.reply(helptext)
.then(() => {
console.info(`[${context.id}] ? scene`);
resolve();
}).catch(err => reject(err));
} else if(context.args) {
context.storyline = context.args;
scenarios.init(context)
.then(context => {
console.info(`[${context.id}] Initiated scenario ${context.args}`);
resolve();
})
.catch(err => reject(err));
} else {
let text = '```\n';
_.each(scenarios.list(context), scenario => text += `${scenario}\n`);
text += '```';
context.message.reply(text)
.then(() => {
console.info(`[${context.id}] Listed scenarios`);
resolve();
})
.catch(err => reject(err));
}
});
}
module.exports = commands => {
commands.scenario = s;
};