mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Use flags
This commit is contained in:
@@ -31,13 +31,17 @@ module.exports = class ChallengerCommand extends Command {
|
||||
reasonURL: 'https://www.smashbros.com/en_US/index.html'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
flags: [
|
||||
{
|
||||
key: 'silhouetted',
|
||||
prompt: 'Should the image be silhouetted?',
|
||||
type: 'boolean',
|
||||
default: true
|
||||
key: 'show',
|
||||
description: 'Does not silhouette the image.'
|
||||
},
|
||||
{
|
||||
key: 's',
|
||||
description: 'Alias for show.'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
@@ -48,7 +52,8 @@ module.exports = class ChallengerCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image, silhouetted }) {
|
||||
async run(msg, { image, flags }) {
|
||||
const silhouetted = flags.show || flags.s;
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
|
||||
@@ -28,6 +28,16 @@ module.exports = class ApplesToApplesCommand extends Command {
|
||||
reason: 'Card Data'
|
||||
}
|
||||
],
|
||||
flags: [
|
||||
{
|
||||
key: 'bot',
|
||||
description: 'Adds the bot as a player.'
|
||||
},
|
||||
{
|
||||
key: 'b',
|
||||
description: 'Alias for bot.'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'maxPts',
|
||||
@@ -37,16 +47,12 @@ module.exports = class ApplesToApplesCommand extends Command {
|
||||
max: 20,
|
||||
min: 1
|
||||
},
|
||||
{
|
||||
key: 'bot',
|
||||
prompt: 'Do you want me to play as well?',
|
||||
type: 'boolean'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { maxPts, bot }) {
|
||||
async run(msg, { maxPts, flags }) {
|
||||
const bot = flags.bot || flags.b;
|
||||
const current = this.client.games.get(msg.channel.id);
|
||||
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
||||
this.client.games.set(msg.channel.id,
|
||||
|
||||
@@ -28,6 +28,16 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
|
||||
reason: 'Card Data'
|
||||
}
|
||||
],
|
||||
flags: [
|
||||
{
|
||||
key: 'bot',
|
||||
description: 'Adds the bot as a player.'
|
||||
},
|
||||
{
|
||||
key: 'b',
|
||||
description: 'Alias for bot.'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'maxPts',
|
||||
@@ -36,17 +46,13 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
|
||||
type: 'integer',
|
||||
max: 20,
|
||||
min: 1
|
||||
},
|
||||
{
|
||||
key: 'bot',
|
||||
prompt: 'Do you want me to play as well?',
|
||||
type: 'boolean'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { maxPts, bot }) {
|
||||
async run(msg, { maxPts, flags }) {
|
||||
const bot = flags.bot || flags.b;
|
||||
const current = this.client.games.get(msg.channel.id);
|
||||
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
||||
this.client.games.set(msg.channel.id,
|
||||
|
||||
@@ -55,6 +55,16 @@ module.exports = class PokedexBoxSpriteCommand extends Command {
|
||||
reasonURL: 'https://play.pokemonshowdown.com/sprites/'
|
||||
}
|
||||
],
|
||||
flags: [
|
||||
{
|
||||
key: 'small',
|
||||
description: 'Generates the image with the original 40x30 size.'
|
||||
},
|
||||
{
|
||||
key: 's',
|
||||
description: 'Alias for small.'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'pokemon',
|
||||
@@ -65,22 +75,23 @@ module.exports = class PokedexBoxSpriteCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { pokemon }) {
|
||||
async run(msg, { pokemon, flags }) {
|
||||
if (!this.client.pokemon.sprites) await this.client.pokemon.loadSprites();
|
||||
const canvas = createCanvas(250, 250);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const x = 40 * (pokemon.id % 12);
|
||||
const y = Math.floor(pokemon.id / 12) * 30;
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
const ratio = 250 / 40;
|
||||
const height = 30 * ratio;
|
||||
ctx.drawImage(this.client.pokemon.sprites, x, y, 40, 30, 0, 0, 250, height);
|
||||
cropToContent(ctx, canvas, canvas.width, canvas.height);
|
||||
return msg.say(`#${pokemon.displayID} - ${pokemon.name}`, {
|
||||
files: [{
|
||||
attachment: canvas.toBuffer(),
|
||||
name: 'box.png'
|
||||
}]
|
||||
});
|
||||
let attachment;
|
||||
if (flags.small || flags.s) {
|
||||
attachment = await pokemon.generateBoxImage();
|
||||
} else {
|
||||
const x = 40 * (pokemon.id % 12);
|
||||
const y = Math.floor(pokemon.id / 12) * 30;
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
const ratio = 250 / 40;
|
||||
const height = 30 * ratio;
|
||||
ctx.drawImage(this.client.pokemon.sprites, x, y, 40, 30, 0, 0, 250, height);
|
||||
cropToContent(ctx, canvas, canvas.width, canvas.height);
|
||||
attachment = canvas.toBuffer();
|
||||
}
|
||||
return msg.say(`#${pokemon.displayID} - ${pokemon.name}`, { files: [{ attachment, name: 'box.png' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,6 +9,16 @@ module.exports = class DrawCardsCommand extends Command {
|
||||
group: 'random-res',
|
||||
memberName: 'draw-cards',
|
||||
description: 'Draws a random hand of playing cards.',
|
||||
flags: [
|
||||
{
|
||||
key: 'jokers',
|
||||
description: 'Includes jokers in the deck.'
|
||||
},
|
||||
{
|
||||
key: 'j',
|
||||
description: 'Alias for bot.'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'amount',
|
||||
@@ -17,19 +27,13 @@ module.exports = class DrawCardsCommand extends Command {
|
||||
type: 'integer',
|
||||
max: 10,
|
||||
min: 1
|
||||
},
|
||||
{
|
||||
key: 'jokers',
|
||||
prompt: 'Do you want the deck to include jokers?',
|
||||
type: 'boolean',
|
||||
default: false
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { amount, jokers }) {
|
||||
const deck = new Deck({ includeJokers: jokers });
|
||||
run(msg, { amount, flags }) {
|
||||
const deck = new Deck({ includeJokers: Boolean(flags.jokers || flags.j) });
|
||||
const cards = deck.draw(amount);
|
||||
const display = Array.isArray(cards) ? cards.map(c => c.display).join('\n') : cards.display;
|
||||
return msg.reply(`${amount === 1 ? '' : '\n'}${display}`);
|
||||
|
||||
Reference in New Issue
Block a user