Add Juustobotti interpretation
This commit is contained in:
parent
945e4f439f
commit
f247f3b2de
2 changed files with 38 additions and 6 deletions
40
index.js
40
index.js
|
@ -2,6 +2,24 @@ const dc = require("discord.js");
|
|||
const client = new dc.Client({intents: ["GUILDS", "GUILD_MESSAGES"]});
|
||||
const fs = require("fs");
|
||||
|
||||
function parseCommands(){
|
||||
var cmdFiles = [];
|
||||
var indexes = {}
|
||||
var rootdir = fs.readdirSync("Juustobotti/commands");
|
||||
rootdir.forEach(categorydir => {
|
||||
categorydir.forEach(file => {
|
||||
indexes.file = categorydir;
|
||||
cmdFiles.push(file);
|
||||
});
|
||||
});
|
||||
var cmds = [];
|
||||
cmdFiles.forEach(yes => {
|
||||
var cmdObj = require("./Juustobotti/commands/" + indexes[yes] + "/yes");
|
||||
cmds.push(cmdObj);
|
||||
});
|
||||
return cmds;
|
||||
}
|
||||
|
||||
var shapes = ["rock", "paper", "scissors"];
|
||||
function rps(shape){
|
||||
shape = shape.toLowerCase();
|
||||
|
@ -135,12 +153,22 @@ client.on("interactionCreate", (int) => {
|
|||
|
||||
const allowed = ["831598877320413244"];
|
||||
client.on("messageCreate", (msg) => {
|
||||
if(!msg.content.startsWith("rps!ev")) return;
|
||||
if(!allowed.includes(msg.author.id)) return msg.channel.send("Nu perms!");
|
||||
try{
|
||||
msg.channel.send(new String(eval(msg.content.replace("rps!ev", ""))).valueOf()).catch(e => {msg.channel.send(e.stack)});
|
||||
} catch(e){
|
||||
msg.channel.send(e.stack).catch(e => {msg.channel.send("Well thats ironic, an error for an error message: \n" + e.stack)});
|
||||
if(msg.content.startsWith("rps!ev")){
|
||||
if(!allowed.includes(msg.author.id)) return msg.channel.send("Nu perms!");
|
||||
try{
|
||||
msg.channel.send(new String(eval(msg.content.replace("rps!ev", ""))).valueOf()).catch(e => {msg.channel.send(e.stack)});
|
||||
} catch(e){
|
||||
msg.channel.send(e.stack).catch(e => {msg.channel.send("Well thats ironic, an error for an error message: \n" + e.stack)});
|
||||
}
|
||||
} else if(msg.content.startsWith("rps!ju")){
|
||||
var commands = parseCommands();
|
||||
commands.forEach(cmd => {
|
||||
if(msg.content.startsWith("rps!ju " + cmd.name)){
|
||||
msg.content = msg.content.replace("rps!ju " + cmd.name, "ju!" + cmd.name);
|
||||
const args = msg.content.slice("ju!".length).trim().split(/ +/);
|
||||
cmd.execute(msg, args);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
4
start.sh
4
start.sh
|
@ -1,4 +1,8 @@
|
|||
while [ true ]
|
||||
do
|
||||
rm -rf Juustobotti
|
||||
git clone https://github.com/Pizzakeitto/Juustobotti.git
|
||||
rm Juustobotti/.git
|
||||
git pull
|
||||
node .
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue