This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fast and easy way to combine (additive mode) two RGBA colors with JavaScript. | |
// [red, green, blue, alpha] based on these maximul values [255, 255, 255, 1]. | |
var base = [69, 109, 160, 1]; | |
var added = [61, 47, 82, 0.8]; | |
var mix = []; | |
mix[3] = 1 - (1 - added[3]) * (1 - base[3]); // alpha | |
mix[0] = Math.round((added[0] * added[3] / mix[3]) + (base[0] * base[3] * (1 - added[3]) / mix[3])); // red | |
mix[1] = Math.round((added[1] * added[3] / mix[3]) + (base[1] * base[3] * (1 - added[3]) / mix[3])); // green | |
mix[2] = Math.round((added[2] * added[3] / mix[3]) + (base[2] * base[3] * (1 - added[3]) / mix[3])); // blue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Include this at the very top of both your main and window processes, so that | |
// it loads as soon as possible. | |
// | |
// Why does this work? The node.js module system calls fs.realpathSync a _lot_ | |
// to load stuff, which in turn, has to call fs.lstatSync a _lot_. While you | |
// generally can't cache stat() results because they change behind your back | |
// (i.e. another program opens a file, then you stat it, the stats change), | |
// caching it for a very short period of time is :ok: :gem:. These effects are | |
// especially apparent on Windows, where stat() is far more expensive - stat() | |
// calls often take more time in the perf graph than actually evaluating the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Client } = require('discord.js'); | |
const client = new Client(); | |
client.on('ready', () => { | |
console.log('Ready!'); | |
}); | |
const events = { | |
MESSAGE_REACTION_ADD: 'messageReactionAdd', | |
MESSAGE_REACTION_REMOVE: 'messageReactionRemove', |