Skip to content

Instantly share code, notes, and snippets.

@midknightmare666
Created July 30, 2019 19:09
Show Gist options
  • Save midknightmare666/e14e4b1fc971425012a2cd585d00749f to your computer and use it in GitHub Desktop.
Save midknightmare666/e14e4b1fc971425012a2cd585d00749f to your computer and use it in GitHub Desktop.
/**
* toHex(inputNumber)
*
* @param {number} inputNumber
* @return {string} hash
*
* @example
*
* toHex(394540642987933707 + Date.now())
*
*/
const toHex = (inputNumber) => {
let hash = '',
alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
alphabetLength = alphabet.length;
do {
hash = alphabet[inputNumber % alphabetLength] + hash;
inputNumber = parseInt(inputNumber / alphabetLength, 10);
} while (inputNumber);
return hash
};
let userId = parseInt(message.author.id);
message.channel.send(`**userName:** ${message.author.username}
\n**userId:** ${message.author.id}
\n**userHex:** ${toHex(userId + Date.now())}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment