Skip to content

Instantly share code, notes, and snippets.

View midknightmare666's full-sized avatar
🏠
Working from home

midknighmare midknightmare666

🏠
Working from home
View GitHub Profile
/**
* toHex(inputNumber)
*
* @param {number} inputNumber
* @return {string} hash
*
* @example
*
* toHex(394540642987933707 + Date.now())
*
/**
* COMMAND CONFIG:
*
* name: String Command Name
* aliases: Array Alias for this command in case user doesn't know how to spell. Leave empty array if no alias is needed.
* des: String Short description for this command. No paragraphs!
* usage: String If command has any paramaters. Leave 1 space if no usage needed. Do not type the command name either! <> = required () = optional
* guildOnly: Boolean If command can be run in dm or guild. Default: true
* ownerOnly: Boolean If command is owner only. Deafault: false
* permLevel: Array The permissions the guildMember must have to run this command.
>>> ** Month, Year **
( Post Patch Notes For: ` 0.0.00.000 ` )
** Bug Fixes **
✅ • Bug Fix Here
✅ • Bug Fix Here
✅ • Bug Fix Here
** Changes **
✅ • Changes Done Here
/**
* Creates a short id from a string of numbers.
*
* @param {String} inputNumber The number to hash
* @return {String} hash The hashed string
*/
module.exports = (inputNumber) => {
let hash = '';
const alphabet = '23456789abcdefghijklmnopqrstuvwxyz';
const length = alphabet.length;
/**
* Round a number to a given decimal point.
*
* @function preciseRound
*
* @param {Number} value The number to be rounded.
* @param {Number} decimals=1 The decimal places to round to (defaults to 1).
* @returns {Number} rounded The final rounded number.
* @example
* preciseRound(196.2000702, 1) => 196.2
@midknightmare666
midknightmare666 / app.js
Last active November 5, 2019 19:50
Dynamically load express routes from subfolder
/* main express file: app.js */
const express = require('express')
const app = express()
// other middleware
require('./routes')(app)
@midknightmare666
midknightmare666 / randomInt.js
Created April 30, 2020 19:10
Generate A Random Number Withing A Range But Exclude A Subset Of Numbers
/**
* @function randomInt
* @description Generate A Random Number Withing A Range But Exclude A Subset Of Numbers
*
* @param {Number} min Minumum Number
* @param {Number} max Maximum Number
* @param {Array<Number>} exclude Array Of Numbers To Exclude
* @returns {Number}
* @example randomInt(2, 10, [3, 5, 7])
*/
/** Import getPlace function **/
const { getPlace } = require('someFilePath...')
/**
* @function getData
* @description requires object of { placeName: placeId }, fetches game player stats and sets
* discord voice channel name to placeName: amountOfPlayers
**/
const exampleImages = [
'example_0.jpg',
'example_1.jpg',
'example_2.jpg'
]
let currentIndex = -1;
/**
* @function setBanner
/* eslint-disable no-param-reassign */
/**
* Creates a short unique id from a string of numbers.
*
* @param {String} inputNumber The number to hash
* @return {String} hash The hashed string
*/
module.exports = (inputNumber) => {