a random nonsense generator
because of an inside joke
do whatever the fuck you want with this
| const { Client, Intents } = require("discord.js"); | |
| const { Profanity, ProfanityOptions } = require('@2toad/profanity'); | |
| const { token, clientid } = require('./config.json'); | |
| const axios = require("axios"); | |
| const client = new Client({intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ]}) | |
| const options = new ProfanityOptions(); | |
| options.wholeWord = false; | |
| options.grawlix = '[REDACTED]'; | |
| const spf = new Profanity(options) | |
| function getRandomInt(min, max) { | |
| min = Math.ceil(min); | |
| max = Math.floor(max); | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } | |
| client.on("ready", ()=> console.log("- CirnoBot Initialized -")) | |
| client.on("messageCreate", async message=> { | |
| if (message.author.bot) return; | |
| if (!message.content.startsWith(`<@${clientid}>`)) return | |
| count = getRandomInt(1,15) | |
| console.log(count) | |
| let response = await axios.get(`https://random-word-api.herokuapp.com/word?number=${count}`).catch(e => console.error(e)) | |
| let sentence = response.data | |
| sentence = sentence.map(element => { | |
| let randCapsChance = (Math.random() < 0.25) | |
| if (randCapsChance) return element.charAt(0).toUpperCase() + element.slice(1); else return element | |
| }); | |
| sentence = sentence.join(" ") | |
| sentence = spf.censor(sentence) | |
| message.reply(sentence) | |
| }) | |
| client.login(token) |
| { | |
| "name": "cirnobot", | |
| "version": "0.1.0", | |
| "description": "CirnoBot (nonsense generator)", | |
| "main": "main.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "author": "Luihum", | |
| "license": "ISC", | |
| "dependencies": { | |
| "@2toad/profanity": "^2.2.0", | |
| "axios": "^1.1.2", | |
| "discord.js": "^13.11.0" | |
| } | |
| } |