/
colour.js
125 lines (119 loc) 路 2.81 KB
/
colour.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* @file colour command
* @author Sankarsan Kampa (a.k.a k3rn31p4nic)
* @license MIT
*/
const convert = require('color-convert');
exports.exec = (Bastion, message, args) => {
if (args.color && /^#?[0-9a-f]{6}$/i.test(args.color)) {
args.color = args.color.replace('#', '');
}
else if (args.random) {
args.color = '000000'.replace(/0/g, () => (~~(Math.random() * 16)).toString(16));
}
else {
/**
* The command was ran with invalid parameters.
* @fires commandUsage
*/
return Bastion.emit('commandUsage', message, this.help);
}
message.channel.send({
embed: {
color: parseInt(args.color, 16),
fields: [
{
name: 'HEX',
value: `#${args.color}`,
inline: true
},
{
name: 'RGB',
value: `${convert.hex.rgb(args.color)}`,
inline: true
},
{
name: 'CMYK',
value: `${convert.hex.cmyk(args.color)}`,
inline: true
},
{
name: 'HSL',
value: `${convert.hex.hsl(args.color)}`,
inline: true
},
{
name: 'HSV',
value: `${convert.hex.hsv(args.color)}`,
inline: true
},
{
name: 'HWB',
value: `${convert.hex.hwb(args.color)}`,
inline: true
},
{
name: 'LAB',
value: `${convert.hex.lab(args.color)}`,
inline: true
},
{
name: 'ANSI16',
value: `${convert.hex.ansi16(args.color)}`,
inline: true
},
{
name: 'ANSI256',
value: `${convert.hex.ansi256(args.color)}`,
inline: true
},
{
name: 'XYZ',
value: `${convert.hex.xyz(args.color)}`,
inline: true
},
{
name: 'HCG',
value: `${convert.hex.hcg(args.color)}`,
inline: true
},
{
name: 'Apple',
value: `${convert.hex.apple(args.color)}`,
inline: true
},
{
name: 'Gray',
value: `${convert.hex.gray(args.color)}`,
inline: true
},
{
name: 'CSS Keyword (Approx.)',
value: `${convert.hex.keyword(args.color)}`,
inline: true
}
],
thumbnail: {
url: `https://dummyimage.com/250/${args.color}/&text=%20`
}
}
}).catch(e => {
Bastion.log.error(e);
});
};
exports.config = {
aliases: [ 'color' ],
enabled: true,
argsDefinitions: [
{ name: 'color', type: String, defaultOption: true },
{ name: 'random', type: Boolean }
]
};
exports.help = {
name: 'colour',
botPermission: '',
userTextPermission: '',
userVoicePermission: '',
usage: 'colour <#hex-colour-code>',
example: [ 'colour #dd0000' ]
};