Skip to content

Instantly share code, notes, and snippets.

@luihum
Last active October 9, 2022 00:22
Show Gist options
  • Save luihum/bb57cdfc90e1df192734a2b6ee74783a to your computer and use it in GitHub Desktop.
Save luihum/bb57cdfc90e1df192734a2b6ee74783a to your computer and use it in GitHub Desktop.
CirnoBot

CirnoBot

what is this?

a random nonsense generator

why is it named after a touhou character

because of an inside joke

what's the license?

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"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment