Skip to content

Instantly share code, notes, and snippets.

View Rageous0's full-sized avatar
๐Ÿ˜

Rageous0

๐Ÿ˜
View GitHub Profile
fs.readdir(`${__dirname}/commands/`, (err, dirs) => {
dirs.forEach(dir => {
fs.readdir(`${__dirname}/commands/${dir}`, (error, file) => {
let jsfile = file.filter(f => f.split(".").pop() === "js");
jsfile.forEach((f, i) => {
let pathx = `./commands/${dir}/${f}`;
let props = require(pathx);
console.log(`${f} running!`);
let cmdn = path.basename(pathx).toString().slice(0, -3);
bot.commands.set(cmdn, props);
@Rageous0
Rageous0 / clearcache.js
Created February 2, 2019 09:52
Clear cache of JSON (NodeJS).
delete require.cache[require.resolve(`PATH`)];
/*
Specify a string as the filepath.
This will clear cache of JSON file (NodeJS).
*/
let rps = ["scissors", "paper", "rock"];
let i;
if(!rps.includes(args[0])) return message.reply("Please choose rock, paper or scissor.");
if(args[0].includes("rock")) {
i = 2;
}
if(args[0].includes("paper")) {
i = 1;
}
if(args[0].includes("scissors")) {
@Rageous0
Rageous0 / int-validator.js
Created November 5, 2018 17:33
Ineger validator JavaScript. (Not tested)
function intval(integer) {
this.integer = integer;
this.res = function() {
let result;
let ints = [0,1,2,3,4,5,6,7,8,9];
let parsedInt;
if(isNaN(this.integer) || typeof this.integer !== "number") {
result = false;
}
if(!this.integer.include(ints)) {