This snippet will generate alphanumeric character. You can modify the number of characters, and the list of letters or numbers to generate. See code comments for further information.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const NUMBER_OF_CHARACTERS = 7; //This is the number of characters that you want to generate
const LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // This is where we will grab the characters
let getRandomAlphaNum = async () => {
let generatedAlphaNum = '';
for (var i = 0; i < NUMBER_OF_CHARACTERS; i++) {
generatedAlphaNum += LETTERS[Math.floor(Math.random() * LETTERS.length)];
}
return generatedAlphaNum;
};
return lib.discord.channels['@0.3.0'].messages.create({
"channel_id": `${context.params.event.channel_id}`,
"content": "",
"tts": false,
"embeds": [
{
"type": "rich",
"title": `Random Alphanumeric Generator`,
"description": "The generated alpha numeric character is: " + await getRandomAlphaNum(),
"color": 0x00FFFF
}
]
});