Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const botSettings = require("./botsettings.json");
- const Discord = require("discord.js");
- const fs = require("fs");
- const prefix = botSettings.prefix;
- const bot = new Discord.Client({disableEveryone: true});
- bot.commands = new Discord.Collection();
- bot.aliases = new Discord.Collection();
- bot.events = new Discord.Collection();
- fs.readdir("./commands/", (err,files) => {
- if(err) console.log(err);
- let jsfile = files.filter(f => f.split(".").pop() === "js");
- if(jsfile.length <= 0) {
- console.log("No commands loaded");
- return;
- }
- console.log(`Loading ${jsfile.length} commands`);
- jsfile.forEach((f,i) => {
- let props = require(`./commands/${f}`);
- console.log(`${i + 1}: ${f} commands loaded`);
- bot.commands.set(props.help.name,props);
- });
- });
- // [START] Ładowanie plików wydarzeń
- fs.readdir("./events/", (err,files) => {
- if(err) console.log(err);
- let jsfile = files.filter(f => f.split(".").pop() === "js");
- if(jsfile.length <= 0) {
- console.log("no events command");
- return;
- }
- console.log(`Loading ${jsfile.length} commands`);
- jsfile.forEach((f,i) => {
- let eventFunc = require(`./events/${f}`);
- console.log(`${i + 1}: ${f} events loaded`);
- let eventName = `${f}`;
- bot.on(eventName, (...args) => eventFunc.run(client, ...args));
- });
- });
- // [KONIEC] Ładowanie plików wydarzeń
- bot.on("ready", async() => {
- console.log(`Bot is ready ! ${bot.user.username} `);
- console.log(bot.commands);
- try {
- let link = await bot.generateInvite(["ADMINISTRATOR"]);
- //console.log(link);
- } catch (e) {
- console.log(e.stack);
- }
- });
- bot.on("message", async message => {
- if(message.author.bot) return;
- if(message.channel.type === "dm") return;
- let messageArray = message.content.split(" ");
- let command = messageArray[0];
- let args = messageArray.slice(1);
- if(!command.startsWith(prefix)) return;
- let cmd = bot.commands.get(command.slice(prefix.length));
- if(cmd) cmd.run(bot, message,args);
- });
- bot.login(botSettings.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement