diff --git a/README.md b/README.md index 5422583..934d314 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,18 @@ # handler-discord.js ### By: ArviX#8443 +#### V2 Base Bot for discord.js **IF YOU WON TO USE THIS BASE BOT HANDLER, YOU MUST SAVE MY LICENCE AND COPYRIGHTS** ##Init - You must just change token and owner id in config.json file -- You can change the prefix and the base Footer in main.js file \ No newline at end of file +- You can change the prefix and the base Footer in main.js file + +##Patchnotes +###V2 +- Added - Error handling +- Added - Better Permission management (Owner, Bot Not Allowed) +- Added - Cool Starting message +- Added - Default Bot Status before status update +- Added - Required Bot Permissions diff --git a/config.json b/config.json index ab40161..f8d8be3 100644 --- a/config.json +++ b/config.json @@ -2,5 +2,10 @@ "token":"YOUR_SUPER_SECRET_BOT_TOKEN", "owner": { "id": "YOUR_ID" - } + }, + "owners": [ + "OWNER_1_ID", + "OWNER_2_ID", + "OWNER_3_ID" + ] } \ No newline at end of file diff --git a/events/message.js b/events/message.js index 8ed9e22..ac8a259 100644 --- a/events/message.js +++ b/events/message.js @@ -4,7 +4,7 @@ * See LICENSE file */ module.exports = (client, message) => { - if (message.author.bot || !message.channel.guild) { + if (!message.channel.guild) { return ; } @@ -21,11 +21,27 @@ module.exports = (client, message) => { if (!command) { return ; } - if(command.perms !== 'everyone') { - if(!message.member.hasPermission(command.perms)) { - return message.channel.send('You don\'t have required permission to use that command!') + if(command.botNotAllowed && message.author.bot) { + return; + } + + if(command.perms === "owner") { + if(!client.config.owners.includes(message.author.id)) { + return message.channel.send('You don\'t have required permission to use that command!'); + } + } + else if(command.perms !== 'everyone') { + if(!message.member.permission.has(command.perms)) { + return message.channel.send('You don\'t have required permission to use that command!'); } } + if(command.botPerms !== []) { + for(botPerm of command.botPerms) { + if(!message.guild.members.cache.get(client.user.id).hasPermission(botPerm)) { + return message.channel.send(`I don\'t have required permission to execute that command!\nMissing Permission: ${botPerm}`); + } + } + } /* * Copyright 2020 © LordAlex2015 * See LICENSE file diff --git a/events/ready.js b/events/ready.js index d4b0a54..d1b0055 100644 --- a/events/ready.js +++ b/events/ready.js @@ -1,6 +1,6 @@ 'use strict'; const {blue} = require('colors'); -module.exports = (client) => { +module.exports = async(client) => { /* * Copyright 2020 © LordAlex2015 * See LICENSE file @@ -8,7 +8,11 @@ module.exports = (client) => { console.log(`Logged in as ${blue(`${client.user.tag}`)}`); - const activities = [`Base Bot | !help`,'By: ArviX#8443 | Base Bot'] + await client.setActivity('Base Bot is Starting...'); + console.log(`${green('[Bot]')} Playing: ${blue('Base Bot is Starting...')}`); + + + const activities = [`Base Bot | !help`,'By: ArviX#8443 | Base Bot']; setInterval(async () => { await client.setActivity(activities[Math.floor(Math.random() * activities.length)]); }, diff --git a/main.js b/main.js index a58faf8..8325539 100644 --- a/main.js +++ b/main.js @@ -4,15 +4,15 @@ const { token } = require('./config.json'), { Client, Collection } = require('discord.js'), { readdirSync } = require('fs'), { join } = require("path"), - {green,red, blue} = require('colors'); + {green,red, blue} = require('colors'), + {text} = require('figlet'); /* * Copyright 2020 © LordAlex2015 * See LICENSE file */ class Class extends Client { constructor(token) { - super({messageCacheMaxSize: 15}); - this.bot = this; + super({messageCacheMaxSize: 15 /* Here you can add PARTIALS */}); this.config = require('./config.json'); this.maincolor = 11007; this.prefix = '!'; @@ -35,6 +35,51 @@ class Class extends Client { this.commands = new Collection(); this._commandsHandler(); this._eventsHandler(); + //Custom Starting Message + text('Handler-Discord.js', { + font: "Standard" + }, function(err, data) { + if (err) { + console.log('Something went wrong...'); + console.dir(err); + return; + } + const data2 = data; + text('By: ArviX', { + }, function(err, data) { + if (err) { + console.log('Something went wrong...'); + console.dir(err); + return; + } + console.log("================================================================================================================================"+"\n"+ + data2+"\n\n"+ data +"\n"+ + "================================================================================================================================" + + ); + }); + + }); + process.on('unhandledRejection', error => { + if(error.code === 50007) return + console.error(green('✅ An Error has occured : ') + red(error.stack)); + let details = `\`\`\`\nName : ${error.name}\nMessage : ${error.message}` + if (error.path) details += `\nPath : ${error.path}` + if (error.code) details += `\nError Code : ${error.code}` + if (error.method) details += `\nMethod : ${error.method}` + if (this.users) this.users.cache.get(this.config.owner.id).send({ + embed: { + description: `🔺 **An Error has occured:**\n\`\`\`js\n${error}\`\`\``, + color: this.maincolor, + fields: [ + { + name: "🔺 Details :", + value: `${details}\`\`\`` + } + ] + } + }) + }); } _commandsHandler() { diff --git a/package.json b/package.json index ba051a0..6f66b73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "handler-discord", - "version": "1.0.0", + "version": "2.0.0", "description": "Handler en Class pour Discord.js", "main": "main.js", "scripts": { @@ -17,8 +17,9 @@ }, "homepage": "https://github.com/LordAlex2015/handler-discord.js#readme", "dependencies": { - "colors": "^1.4.0", - "discord.js": "^12.2.0", - "moment": "^2.27.0" + "colors": "latest", + "discord.js": "latest", + "moment": "latest", + "figlet": "latest" } } diff --git a/structure/Command.js b/structure/Command.js index abfca04..2c92574 100644 --- a/structure/Command.js +++ b/structure/Command.js @@ -7,5 +7,7 @@ module.exports = class Command { this.example = info.example || []; this.aliases = info.aliases || []; this.perms = info.perms || 'everyone'; + this.botNotAllowed = info.botNotAllowed || true; + this.botPerms = info.botPerms || []; } };