diff --git a/zoizbot/app.js b/zoizbot/app.js index 80aea06..63cd9f5 100644 --- a/zoizbot/app.js +++ b/zoizbot/app.js @@ -7,34 +7,25 @@ var fs = require('fs'); zoizbot.commands = new Discord.Collection(); -console.log("=============================================="); -console.log(`starting zoizbot...`); +console.log(" =============================================="); +console.log(` starting zoizbot...`); eval(fs.readFileSync('./bootscreen.js') + ''); // please delete this, using readFileSync 1 time was bad enough. But I didnt want ascii art in my main file ;) -console.log(`loading configuration file...`) +console.log(` loading configuration file...`) const config = require("./conf.json"); // de conf ophalen die we net gemaakt hadden / picking up the config file we made -console.log(`configuration loaded!`) // should make an catch error to debug conf file but whatever -console.log("=============================================="); -console.log(`loading the commandhandler...`) +console.log(` configuration loaded!`) // should make an catch error to debug conf file but whatever +console.log(" =============================================="); +console.log(` loading the commandhandler...`) eval(fs.readFileSync('./commandhandler.js') + ''); -console.log(`commandhandler loaded!`) -console.log("=============================================="); -console.log(`loading command-files...`) +console.log(` commandhandler loaded!`) +console.log(" =============================================="); +console.log(" ") +console.log(` loading command-files...`) +console.log(" ") -fs.readdir(`./commands/`, (err, files) => { - if (err) return console.error(err); - files.forEach(file => { - if (!file.endsWith(".js")) return; // only load js files. no garbage collection - let props = require(`./commands/${file}`); // get the command name from the file.js - let commandName = file.split(".")[0]; - console.log(`attempting to load command ${commandName}`); // adding everything to the collection - zoizbot.commands.set(commandName, props); - }); - console.log(`all commands loaded!`); - console.log("=============================================="); -}); +eval(fs.readFileSync('./commandloader.js') + ''); // Loading from command folders. easy mode :) zoizbot.login(config.token).catch(console.error); //reading the "token" from the const config = conf.json btw the one you see is invalid now \ No newline at end of file diff --git a/zoizbot/bootscreen.js b/zoizbot/bootscreen.js index 62bbfe4..1c3ba74 100644 --- a/zoizbot/bootscreen.js +++ b/zoizbot/bootscreen.js @@ -1,15 +1,15 @@ // bad practice please remove this file and the fileReadSync function -console.log("=============================================="); -console.log(" ,--, "); -console.log(" ,----, ,---. ,--.'| ,----, "); -console.log(" .' .`| ' ,'\ | |, .' .`| "); -console.log(" .' .' .' / / |`--'_ .' .' .' "); -console.log(",---, ' ./ . ; ,. :,' ,'| ,---, ' ./ "); -console.log("; | .' / ' | |: :' | | ; | .' / "); -console.log("`---' / ;--,' | .; :| | : `---' / ;--, "); -console.log(" / / / .`|| : |' : |__ / / / .`| "); -console.log("./__; .' \ \ / | | '.'|./__; .' "); -console.log("; | .' `----' ; : ;; | .' "); -console.log("`---' | , / `---' "); -console.log(" ---`-' "); -console.log("=============================================="); +console.log(" =============================================="); +console.log(" ,--, "); +console.log(" ,----, ,---. ,--.'| ,----, "); +console.log(" .' .`| ' ,'\ | |, .' .`| "); +console.log(" .' .' .' / / | `--'_ .' .' .' "); +console.log(" ,---, ' ./ . ; ,. : ,' ,'| ,---, ' ./ "); +console.log(" ; | .' / ' | |: : ' | | ; | .' / "); +console.log(" `---' / ;--,' | .; : | | : `---' / ;--, "); +console.log(" / / / .`|| : | ' : | / / / .`| "); +console.log(" ./__; .' \ \ / | | | /__; .' "); +console.log(" ; | .' `----' ; : | ;; | .' "); +console.log(" `---' | , : `---' "); +console.log(" ---` "); +console.log(" =============================================="); diff --git a/zoizbot/commandhandler.js b/zoizbot/commandhandler.js index 8127546..c328236 100644 --- a/zoizbot/commandhandler.js +++ b/zoizbot/commandhandler.js @@ -1,16 +1,17 @@ zoizbot.on("ready", () => { zoizbot.user.setActivity(config.activity); // change this to whatever you want (in conf.json). - console.log(`Zoizbot has started, and is serving ${zoizbot.users.cache.size} users, in ${zoizbot.guilds.cache.size} guilds.`); // you can display anything you want here, all the functions are available in de documentation from discord.js - console.log("==================LISTENING==================="); + console.log(` Zoizbot is listening, `); // you can display anything you want here, all the functions are available in de documentation from discord.js + console.log(` and is currently serving ${ zoizbot.users.cache.size } users, in ${ zoizbot.guilds.cache.size } guilds.`) + console.log(" ==================LISTENING==================="); }); zoizbot.on("guildJoin", guild => { - console.log(`I have joined ${guild.name}, I will be serving ${guild.memberCount} members!`); // Join server message in the console - message.channel.send(`Hello ${guild.name} thank you for having me!`); + console.log(` I have joined ${guild.name}, I will be serving ${guild.memberCount} members!`); // Join server message in the console + message.channel.send(` Hello ${guild.name} thank you for having me!`); }); zoizbot.on("guildLeave", guild => { - console.log(`Adios! i will be leaving: ${guild.name}, it was fun while it lasted!`); //letting you know he be headin out + console.log(` Adios! i will be leaving: ${guild.name}, it was fun while it lasted!`); //letting you know he be headin out }); zoizbot.on("message", async message => { diff --git a/zoizbot/commandloader.js b/zoizbot/commandloader.js new file mode 100644 index 0000000..d54fe3f --- /dev/null +++ b/zoizbot/commandloader.js @@ -0,0 +1,69 @@ +var loaded = 0 +fs.readdir (`./commands/`, (err, files) => { + if (err) return console.error(err); + files.forEach(file => { + if (!file.endsWith(".js")) return; // only load js files. no garbage collection + let props = require(`./commands/${file}`); // get the command name from the file.js + let commandName = file.split(".")[0]; + console.log(` attempting to load command: ${commandName}`); // adding everything to the collection + zoizbot.commands.set(commandName, props); + loaded++; // beginners trick to check if all the folder-commands where loaded // i really dont know what im doing here hahahaha + }); + if (loaded == 4) { // this is the funniest shit i have ever done. pure for asthetics. please change this to a different way + console.log(" ") + console.log(` all commands loaded!`); + console.log(" ") + console.log(" =============================================="); + } +}); +fs.readdir (`./commands/fun/`, (err, files) => { + if (err) return console.error(err); + files.forEach(file => { + if (!file.endsWith(".js")) return; + let props = require(`./commands/fun/${file}`); + let commandName = file.split(".")[0]; + console.log(` attempting to load command: ${commandName}`); + zoizbot.commands.set(commandName, props); + loaded++; + }); + if (loaded == 4) { + console.log(" ") + console.log(` all commands loaded!`); + console.log(" ") + console.log(" =============================================="); + } +}); +fs.readdir(`./commands/general/`, (err, files) => { + if (err) return console.error(err); + files.forEach(file => { + if (!file.endsWith(".js")) return; + let props = require(`./commands/general/${file}`); + let commandName = file.split(".")[0]; + console.log(` attempting to load command: ${commandName}`); + zoizbot.commands.set(commandName, props); + loaded++; + }); + if (loaded == 4) { + console.log(" ") + console.log(` all commands loaded!`); + console.log(" ") + console.log(" =============================================="); + } +}); +fs.readdir(`./commands/moderation/`, (err, files) => { //copy paste for different folders works fine. dirty fix no.394 haha + if (err) return console.error(err); + files.forEach(file => { + if (!file.endsWith(".js")) return; + let props = require(`./commands/moderation/${file}`); + let commandName = file.split(".")[0]; + console.log(` attempting to load command: ${commandName}`); + zoizbot.commands.set(commandName, props); + loaded++; + }); + if (loaded == 4) { + console.log(" ") + console.log(` all commands loaded!`); + console.log(" ") + console.log(" =============================================="); + } +}); diff --git a/zoizbot/commands/hello.js b/zoizbot/commands/general/hello.js similarity index 100% rename from zoizbot/commands/hello.js rename to zoizbot/commands/general/hello.js diff --git a/zoizbot/commands/ping.js b/zoizbot/commands/general/ping.js similarity index 100% rename from zoizbot/commands/ping.js rename to zoizbot/commands/general/ping.js diff --git a/zoizbot/commands/moderation/kick.js b/zoizbot/commands/moderation/kick.js new file mode 100644 index 0000000..33b2531 --- /dev/null +++ b/zoizbot/commands/moderation/kick.js @@ -0,0 +1,18 @@ +exports.run = async (zoizbot, message, args) => { + if (!message.member.hasPermission("KICK_MEMBERS")) + return message.reply("Sorry, you don't have permissions to use this!"); + + let member = message.guild.member(message.mentions.users.first()) || message.mentions.members.first(args[0]) + if (!member) + return message.reply("Please mention a valid member of this server"); + if (!member.kickable) + return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?"); + + let KickReason = args.slice(1).join(' '); // slicing the arguments + if (!KickReason) KickReason = "No reason provided"; + + + await member.kick(KickReason) + .catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`)); // now an adios moment + message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${KickReason}`); +} \ No newline at end of file diff --git a/zoizbot/conf.json b/zoizbot/conf.json index e9ed938..239d0e8 100644 --- a/zoizbot/conf.json +++ b/zoizbot/conf.json @@ -1,4 +1,5 @@ { "token": "", - "prefix": ">" + "prefix": ">", + "activity": "Ask me something with >" } diff --git a/zoizbot/zoizbot.njsproj b/zoizbot/zoizbot.njsproj index 6de7af3..c6aa610 100644 --- a/zoizbot/zoizbot.njsproj +++ b/zoizbot/zoizbot.njsproj @@ -42,10 +42,16 @@ Code - + Code - + + Code + + + Code + + Code @@ -57,6 +63,9 @@ + + +