Add Juustobotti interpretation
This commit is contained in:
parent
945e4f439f
commit
f247f3b2de
2 changed files with 38 additions and 6 deletions
30
index.js
30
index.js
|
@ -2,6 +2,24 @@ const dc = require("discord.js");
|
||||||
const client = new dc.Client({intents: ["GUILDS", "GUILD_MESSAGES"]});
|
const client = new dc.Client({intents: ["GUILDS", "GUILD_MESSAGES"]});
|
||||||
const fs = require("fs");
|
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"];
|
var shapes = ["rock", "paper", "scissors"];
|
||||||
function rps(shape){
|
function rps(shape){
|
||||||
shape = shape.toLowerCase();
|
shape = shape.toLowerCase();
|
||||||
|
@ -135,13 +153,23 @@ client.on("interactionCreate", (int) => {
|
||||||
|
|
||||||
const allowed = ["831598877320413244"];
|
const allowed = ["831598877320413244"];
|
||||||
client.on("messageCreate", (msg) => {
|
client.on("messageCreate", (msg) => {
|
||||||
if(!msg.content.startsWith("rps!ev")) return;
|
if(msg.content.startsWith("rps!ev")){
|
||||||
if(!allowed.includes(msg.author.id)) return msg.channel.send("Nu perms!");
|
if(!allowed.includes(msg.author.id)) return msg.channel.send("Nu perms!");
|
||||||
try{
|
try{
|
||||||
msg.channel.send(new String(eval(msg.content.replace("rps!ev", ""))).valueOf()).catch(e => {msg.channel.send(e.stack)});
|
msg.channel.send(new String(eval(msg.content.replace("rps!ev", ""))).valueOf()).catch(e => {msg.channel.send(e.stack)});
|
||||||
} catch(e){
|
} catch(e){
|
||||||
msg.channel.send(e.stack).catch(e => {msg.channel.send("Well thats ironic, an error for an error message: \n" + e.stack)});
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.login(JSON.parse(fs.readFileSync(".token").toString()));
|
client.login(JSON.parse(fs.readFileSync(".token").toString()));
|
4
start.sh
4
start.sh
|
@ -1,4 +1,8 @@
|
||||||
while [ true ]
|
while [ true ]
|
||||||
do
|
do
|
||||||
|
rm -rf Juustobotti
|
||||||
|
git clone https://github.com/Pizzakeitto/Juustobotti.git
|
||||||
|
rm Juustobotti/.git
|
||||||
|
git pull
|
||||||
node .
|
node .
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue