Skip to content

Instantly share code, notes, and snippets.

View appellation's full-sized avatar

Will Nelson appellation

View GitHub Profile
@appellation
appellation / stripe-countries.json
Last active July 22, 2016 21:58
Countries supported by Stripe, including supported currencies for charges and bank accounts.
{
"countries": [
{
"name": "Australia",
"code": "AU",
"status": "supported"
},
{
"name": "Austria",
"code": "AT",
var chaine = msg.content.split(" ");
// Also, consider using `msg.author.voiceChannel`
bot.joinVoiceChannel(bot.channels.get("name", "Général")).then(function(vc){
var request = require("request");
var url = chaine[1];
var stream = request(url);
return vc.playRawStream(stream);
@appellation
appellation / config.json
Last active December 14, 2016 05:18
Literally the simplest Discord bot.
{
"token": "test token"
}
@appellation
appellation / spellcheck.js
Last active December 25, 2016 07:54
Only practical for Discord selfbots. Use with Discord.js
let rp = require('request-promise-native');
const dns = require('dns');
const os = require('os');
function checkSpelling(client, text) {
return new Promise((resolve, reject) => {
dns.lookup(os.hostname(), (err, address, family) => {
if(err) return reject(err);
resolve(address);
@appellation
appellation / promises.js
Last active January 6, 2017 17:14
A quick promise chaining demonstration.
// not chaining
asyncFunction().then(data => {
asyncFunction(data).then(data2 => {
asyncFunction(data2);
}).catch(console.error);
});
// chaining
asyncFunction.then(data => {
return asyncFunction(data);
await new Promise((resolve, reject) => {
exec(`fswebcam --fps 15 -S 8 -r ${imgW}x${imgH} --no-banner selfie.jpg`, (error) => {
if (error) return reject(error);
return resolve();
});
});
function Eval(msg, args) {
const input = ':arrow_right: **Input:**\n```js\n' + args.join(' ') + '\n```';
return new Promise((resolve, reject) => {
let ev;
try {
ev = eval(args.join(' '));
if(ev && ev instanceof Promise) {
ev.then(resolve).catch(reject);
@appellation
appellation / camelCase.js
Last active February 13, 2017 22:17
snek_case to camelCase
class Camel {
constructor(data) {
for(const prop in data)
if(data.hasOwnProperty(prop))
this[prop.replace(/_([a-z])/, (match, p1) => p1.toUpperCase())] = data[prop];
}
}
class Ratelimiter {
constructor({ limit = 1, frequency = 5 }) {
this.count = 0;
this.limit = limit;
this.frequency = frequency * 1000;
this._timeout();
}
_timeout() {
const {SettingProvider} = require('discord.js-commando');
const bluebird = require('bluebird');
const redis = require('redis');
const erlpack = require('erlpack');
const mergeOptions = require('merge-options');
bluebird.promisifyAll(redis.RedisClient.prototype);
bluebird.promisifyAll(redis.Multi.prototype);