Skip to content

Commit

Permalink
V2
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
LordAlex2015 committed Nov 25, 2020
1 parent a249934 commit 90f60e4
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 15 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
- 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
7 changes: 6 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"token":"YOUR_SUPER_SECRET_BOT_TOKEN",
"owner": {
"id": "YOUR_ID"
}
},
"owners": [
"OWNER_1_ID",
"OWNER_2_ID",
"OWNER_3_ID"
]
}
24 changes: 20 additions & 4 deletions events/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See LICENSE file
*/
module.exports = (client, message) => {
if (message.author.bot || !message.channel.guild) {
if (!message.channel.guild) {
return ;
}

Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions events/ready.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
'use strict';
const {blue} = require('colors');
module.exports = (client) => {
module.exports = async(client) => {
/*
* Copyright 2020 © LordAlex2015
* See LICENSE file
*/

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)]);
},
Expand Down
51 changes: 48 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '!';
Expand All @@ -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() {
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
}
}
2 changes: 2 additions & 0 deletions structure/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || [];
}
};

0 comments on commit 90f60e4

Please sign in to comment.