mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 05:51:35 +02:00
Add color name
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { createCanvas } = require('canvas');
|
const { createCanvas } = require('canvas');
|
||||||
|
const ntc = require('ntcjs');
|
||||||
|
|
||||||
module.exports = class ColorCommand extends Command {
|
module.exports = class ColorCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -17,9 +18,9 @@ module.exports = class ColorCommand extends Command {
|
|||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'color',
|
key: 'color',
|
||||||
prompt: 'What color do you want to view? This can be #colorcode or a name.',
|
prompt: 'What color do you want to view? This must be a #colorcode.',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
parse: color => color.toLowerCase()
|
validate: color => /^#[0-9A-F]{6}$/i.test(color)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -28,8 +29,11 @@ module.exports = class ColorCommand extends Command {
|
|||||||
run(msg, { color }) {
|
run(msg, { color }) {
|
||||||
const canvas = createCanvas(250, 250);
|
const canvas = createCanvas(250, 250);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.fillStyle = color;
|
const name = ntc.name(color);
|
||||||
|
ctx.fillStyle = color.toLowerCase();
|
||||||
ctx.fillRect(0, 0, 250, 250);
|
ctx.fillRect(0, 0, 250, 250);
|
||||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'color.png' }] });
|
return msg.say(`#${color.toUpperCase()} - ${name[1]}`, {
|
||||||
|
files: [{ attachment: canvas.toBuffer(), name: 'color.png' }]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "135.7.0",
|
"version": "136.0.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -70,6 +70,7 @@
|
|||||||
"moment-timezone": "^0.5.33",
|
"moment-timezone": "^0.5.33",
|
||||||
"node-superfetch": "^0.2.2",
|
"node-superfetch": "^0.2.2",
|
||||||
"nsfwjs": "^2.4.0",
|
"nsfwjs": "^2.4.0",
|
||||||
|
"ntcjs": "^1.1.2",
|
||||||
"parse-domain": "^3.0.3",
|
"parse-domain": "^3.0.3",
|
||||||
"pokersolver": "^2.1.4",
|
"pokersolver": "^2.1.4",
|
||||||
"random-js": "^2.1.0",
|
"random-js": "^2.1.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user