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