Skip to content

Instantly share code, notes, and snippets.

@Jhawins

Jhawins/colors.js

Last active Aug 29, 2015
Embed
What would you like to do?
Supports `-g` flag and strips all others (I expect people to try other flags even though they don't exist)
'use strict';
module.exports = function(bot, IO) {
function color ( args ) {
var outType, base, param;
if ( args.match( /-g/ ) ) { //the only flag for this is g(gradient)
outType = 'gradient=';
} else outType = 'color=';
base = 'http://jhawins.tk/colors.php?';
param = args.toLowerCase()
.replace( /-[a-z]*/, '' )//strip all flags
.match( /([a-z0-9]+)+/g );
args.directreply( base + outType + param + '#.png' );
}
bot.addCommand({
name : 'color',
permissions : {
del : 'NONE'
},
description : 'Displays the' +
'color(s) passed in as RGB, hexadecimal' +
'or hex-shorthand or standard color names' +
'(if it works in CSS it should work here). ' +
' `/color color0[ color1[ ...]]`' +
'use -g for gradient'
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.