From cef297605886d0ab2ed00762c837029dadb5afcb Mon Sep 17 00:00:00 2001 From: Vylpes Date: Fri, 23 Oct 2020 18:33:26 +0100 Subject: [PATCH 01/12] 1.0.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7e1c9a7..1d5dccb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vylbot-core", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2eb919c..b3905f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vylbot-core", - "version": "1.0.0", + "version": "1.0.1", "description": "A discord client based upon discord.js", "main": "./src/index", "scripts": { From d668aee13851c1c55b89712ea497ed61db7c39c6 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Fri, 23 Oct 2020 19:01:49 +0100 Subject: [PATCH 02/12] Removed folder check --- src/client/client.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/client/client.js b/src/client/client.js index 74e75f4..150e5c3 100644 --- a/src/client/client.js +++ b/src/client/client.js @@ -34,10 +34,7 @@ class client extends Client { if (typeof config.prefix != "string") throw "Prefix is not a string"; if (typeof config.commands != "object") throw "Commands is not a string"; - if (!existsSync(`${process.cwd()}/${config.commands}`)) throw "Commands folder doesn't exist"; - if (typeof config.events != "object") throw "Events is not a string"; - if (!existsSync(`${process.cwd()}/${config.events}`)) throw "Events folder doesn't exist"; this._config = config; } From 0a55a1dbae17f32265d8f9bccefdd47d3e1b5641 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Fri, 23 Oct 2020 19:02:13 +0100 Subject: [PATCH 03/12] 1.0.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d5dccb..c3e1225 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vylbot-core", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b3905f3..6d039de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vylbot-core", - "version": "1.0.1", + "version": "1.0.2", "description": "A discord client based upon discord.js", "main": "./src/index", "scripts": { From 160b306439785d97cc433c8abc647ac5bd768e21 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Fri, 23 Oct 2020 19:13:05 +0100 Subject: [PATCH 04/12] Fixed some stuff --- src/client/util.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/client/util.js b/src/client/util.js index 25d0540..20cb9d3 100644 --- a/src/client/util.js +++ b/src/client/util.js @@ -9,14 +9,14 @@ class util { loadCommand(name, args, message) { for (let c = 0; c < this._client.config.commands.length; c++) { let folder = this._client.config.commands[c]; - - stat(`${process.cwd()}/${this._client.config.commands}/${name}.js`, (err, stat) => { + + stat(`${process.cwd()}/${folder}/${name}.js`, (err, stat) => { if (err == null) { let commandFile = require(`${process.cwd()}/${this._client.config.commands}/${name}.js`); let command = new commandFile(); - + let requiredConfigs = command.requiredConfigs; - + for (let i = 0; i < requiredConfigs.length; i++) { if (!this._client.config[name]) throw `${commandFile.name} requires ${requiredConfigs[i]} in it's configuration`; if (!this._client.config[name][requiredConfigs[i]]) throw `${commandFile.name} requires ${requiredConfigs[i]} in it's configuration`; @@ -30,7 +30,7 @@ class util { return; } } - + command[command.run]({ "command": name, "arguments": args, @@ -46,15 +46,19 @@ class util { } loadEvents() { - let eventFiles = readdirSync(`${process.cwd()}/${this._client.config.events}/`); + for (let e = 0; e < this._config.events.length; e++) { + let folder = this._config.events[e]; - for (let i = 0; i < eventFiles.length; i++) { - let eventName = eventFiles[i].split('.')[0]; - let file = require(`${process.cwd()}/${this._client.config.events}/${eventName}.js`); - - let event = new file; - - this._client.on(eventName, event[event.run]); + let eventFiles = readdirSync(`${process.cwd()}/${folder}/`); + + for (let i = 0; i < eventFiles.length; i++) { + let eventName = eventFiles[i].split('.')[0]; + let file = require(`${process.cwd()}/${this._client.config.events}/${eventName}.js`); + + let event = new file; + + this._client.on(eventName, event[event.run]); + } } } } From f2fed721ae4f276c50406c15bdaeab01ce727ee0 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Fri, 23 Oct 2020 19:19:44 +0100 Subject: [PATCH 05/12] Fixed more stuff --- src/client/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/util.js b/src/client/util.js index 20cb9d3..5587190 100644 --- a/src/client/util.js +++ b/src/client/util.js @@ -46,8 +46,8 @@ class util { } loadEvents() { - for (let e = 0; e < this._config.events.length; e++) { - let folder = this._config.events[e]; + for (let e = 0; e < this._client.config.events.length; e++) { + let folder = this._client.config.events[e]; let eventFiles = readdirSync(`${process.cwd()}/${folder}/`); From 22cff6cf2356fde23ab93741715d224a6b82cf92 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Fri, 23 Oct 2020 19:20:04 +0100 Subject: [PATCH 06/12] 1.0.3 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c3e1225..721e092 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vylbot-core", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6d039de..98cba5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vylbot-core", - "version": "1.0.2", + "version": "1.0.3", "description": "A discord client based upon discord.js", "main": "./src/index", "scripts": { From 6b4e7593597b4e184727368625f7f542bb12e57f Mon Sep 17 00:00:00 2001 From: Vylpes Date: Fri, 23 Oct 2020 19:42:50 +0100 Subject: [PATCH 07/12] Fixed bugs --- src/client/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/util.js b/src/client/util.js index 5587190..59228d6 100644 --- a/src/client/util.js +++ b/src/client/util.js @@ -12,7 +12,7 @@ class util { stat(`${process.cwd()}/${folder}/${name}.js`, (err, stat) => { if (err == null) { - let commandFile = require(`${process.cwd()}/${this._client.config.commands}/${name}.js`); + let commandFile = require(`${process.cwd()}/${folder}/${name}.js`); let command = new commandFile(); let requiredConfigs = command.requiredConfigs; @@ -53,7 +53,7 @@ class util { for (let i = 0; i < eventFiles.length; i++) { let eventName = eventFiles[i].split('.')[0]; - let file = require(`${process.cwd()}/${this._client.config.events}/${eventName}.js`); + let file = require(`${process.cwd()}/${folder}/${eventName}.js`); let event = new file; From 0d8828bc40a059a2940752c10c4954e046409f04 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Fri, 23 Oct 2020 19:43:08 +0100 Subject: [PATCH 08/12] 1.0.4 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 721e092..d232b75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vylbot-core", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 98cba5d..cea4d1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vylbot-core", - "version": "1.0.3", + "version": "1.0.4", "description": "A discord client based upon discord.js", "main": "./src/index", "scripts": { From fd61bbf448a665d706ba7e9a746150818f81da61 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Mon, 26 Oct 2020 20:29:14 +0000 Subject: [PATCH 09/12] Added the ability to make the bot only run for specific users --- src/client/util.js | 7 +++++++ src/type/command.js | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/client/util.js b/src/client/util.js index 59228d6..0e99dec 100644 --- a/src/client/util.js +++ b/src/client/util.js @@ -31,6 +31,13 @@ class util { } } + let users = command.users; + + if (!users.includes(message.member.id)) { + message.reply(`You do not have permission to run this command`); + return; + } + command[command.run]({ "command": name, "arguments": args, diff --git a/src/type/command.js b/src/type/command.js index 17f2c75..e3f1885 100644 --- a/src/type/command.js +++ b/src/type/command.js @@ -4,6 +4,7 @@ class command { this._roles = []; this._requiredConfigs = []; + this._users = []; } // Description @@ -50,6 +51,15 @@ class command { set requiredConfigs(conf) { this._requiredConfigs.push(conf); } + + // Users + get users() { + return this._users; + } + + set users(userid) { + this._users.push(userid); + } } module.exports = command; From 44f2f63499ddd4f4ca76a335c6ee42443bae9747 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Mon, 26 Oct 2020 20:33:10 +0000 Subject: [PATCH 10/12] Add documentation about user-specific command settings --- docs/index.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 46e98ab..95fbb79 100644 --- a/docs/index.md +++ b/docs/index.md @@ -67,6 +67,7 @@ class test extends command { super.requiredConfigs = "link"; super.roles = "Moderator"; super.roles = "Admin"; + super.users = ""; } test(context) { @@ -84,11 +85,15 @@ module.exports = test; > **Note:** You can set more than one role to be required by setting `super.roles` again. -5. If you want the command to require a variable in the config, set the name in `super.requiredConfigs` +5. If you want the command to only be ran by specific users, set their ID in `super.users` + +> **Note:** You can set more than one user to be required by settubg `super.users` again. + +6. If you want the command to require a variable in the config, set the name in `super.requiredConfigs` > **Note:** You can set more than one role to be required by setting `super.requiredConfigs` again. -6. Create a method using the name you set in `super(run)`, with the `context` as its parameter. +7. Create a method using the name you set in `super(run)`, with the `context` as its parameter. The `context` parameter will be a JSON object of: From d8860212d212896867f47a46cc94f29c85a7ab9e Mon Sep 17 00:00:00 2001 From: vylpes Date: Wed, 28 Oct 2020 17:53:56 +0000 Subject: [PATCH 11/12] Fix hound violations --- src/client/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/util.js b/src/client/util.js index 0e99dec..632d7f6 100644 --- a/src/client/util.js +++ b/src/client/util.js @@ -10,7 +10,7 @@ class util { for (let c = 0; c < this._client.config.commands.length; c++) { let folder = this._client.config.commands[c]; - stat(`${process.cwd()}/${folder}/${name}.js`, (err, stat) => { + stat(`${process.cwd()}/${folder}/${name}.js`, (err) => { if (err == null) { let commandFile = require(`${process.cwd()}/${folder}/${name}.js`); let command = new commandFile(); From 80122c9bba83770995260bf0d6cdda7dd3f576be Mon Sep 17 00:00:00 2001 From: vylpes Date: Wed, 28 Oct 2020 17:54:40 +0000 Subject: [PATCH 12/12] Fix hound violations --- src/client/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/util.js b/src/client/util.js index 632d7f6..ec42570 100644 --- a/src/client/util.js +++ b/src/client/util.js @@ -10,7 +10,7 @@ class util { for (let c = 0; c < this._client.config.commands.length; c++) { let folder = this._client.config.commands[c]; - stat(`${process.cwd()}/${folder}/${name}.js`, (err) => { + stat(`${process.cwd()}/${folder}/${name}.js`, err => { if (err == null) { let commandFile = require(`${process.cwd()}/${folder}/${name}.js`); let command = new commandFile();