added p/eulogy and the capability for command arguments
This commit is contained in:
parent
ae2eb50b9c
commit
b52b23d495
1 changed files with 28 additions and 0 deletions
28
src/commands/eulogy.js
Normal file
28
src/commands/eulogy.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const fs = require("fs");
|
||||
require("dotenv").config();
|
||||
|
||||
const prefix = process.env.PREFIX;
|
||||
|
||||
module.exports = {
|
||||
name: "eulogy",
|
||||
description: "generates a eulogy",
|
||||
execute(message, args) {
|
||||
const msgnoprefix = message.content.slice(prefix.length + this.name.length);
|
||||
const name = msgnoprefix.slice(0, 2000);
|
||||
const jsonstring = fs.readFileSync("../pepperbot/data/eulogies.json");
|
||||
const parsedeulogies = JSON.parse(jsonstring);
|
||||
const maxRan = parsedeulogies.eulogies.length;
|
||||
|
||||
const randomnum = Math.floor(Math.random() * maxRan);
|
||||
|
||||
const eulogy = parsedeulogies.eulogies[randomnum];
|
||||
|
||||
if (name.replaceAll(" ", "") === "") {
|
||||
message.reply("no name supplied");
|
||||
return;
|
||||
}
|
||||
|
||||
const parsedeulogy = eulogy.replaceAll("##NAME", name);
|
||||
message.reply(parsedeulogy);
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue