This commit is contained in:
Ecolipsy 2021-12-02 18:37:46 +01:00
parent 07a69fa010
commit 432dcee3b1

View file

@ -167,6 +167,10 @@ client.on("interactionCreate", (int) => {
}
});
function doStuff(msg, cmd){
}
const allowed = ["831598877320413244"];
client.on("messageCreate", (msg) => {
if(msg.content.startsWith("rps!ev")){
@ -180,17 +184,41 @@ client.on("messageCreate", (msg) => {
console.log("Was rps!ju");
var commands = parseCommands();
commands.forEach(cmd => {
console.log("Command: " + cmd.name);
if(msg.content.startsWith("rps!ju " + cmd.name)){
var i = 0;
i++;
console.log("Got to %s!", i);
console.log("Was " + cmd.name);
msg.content = msg.content.replace("rps!ju " + cmd.name, "ju!" + cmd.name);
const args = msg.content.slice("ju!".length).trim().split(/ +/);
console.log("Content: %s, args: %s", msg.content, args);
const prefix = "ju!";
if (msg.author.bot) return // If the message is sent by a bot, do nothing
i++;
console.log("Got to %s!", i);
if (msg.mentions.users.has(client.user.id)) {
msg.channel.send(`Why did you ping me??? Do ${prefix}help to see my commands bruh`)
}
if (!msg.content.toLowerCase().startsWith(prefix)) return //If the message doesn't start with the prefix, do nothing
i++;
console.log("Got to %s!", i);
if (!msg.guild) return msg.channel.send("Cant do in dms lol")
i++;
console.log("Got to %s!", i);
const commandName = args.shift().toLowerCase() //gets what the commands name is and makes it lowercase so it aint case sensitive
if (!client.commands.has(commandName)) return msg.channel.send("I don't know that command! Check the available commands with ju!help")
i++;
console.log("Got to %s!", i);
const command = client.commands.get(commandName) //gets the actual command object
try{
cmd.execute(msg, args);
} catch(e){
msg.channel.send("Nope, check console");
console.log(e);
i++;
console.log("Got to %s!", i);
command.execute(msg, args)
} catch (error) {
console.error(error)
msg.reply("There was an error while executing this command! (the error has been logged)")
}
}
});