Skip to content

Commit

Permalink
Reverted!
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximKing1 committed Feb 20, 2021
1 parent 44ccc07 commit 5a11520
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 81 deletions.
17 changes: 0 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ All notable changes to this project will be documented in this file. See [standa

### [1.7.9](https://github.com/MaximKing1/BLWebhooks/compare/v1.7.5...v1.7.9) (2021-02-20)

* **Major Update:** The new manager options will now replace this,
```js
voteClient.extraLogging(true);
```
with this:
```js
const voteClient = WebhooksManager(client, 80, {
database: "mongoose", // mongoose or sqlite for vote logging
extraLogging: true, // This will enable extraLogging {Debugging}
extra: {
extraProtection: true, // Leave Enabled Unless Using Small Amount Of RAM
proxyTrust: false, // Enable this if your behind a proxy, Heroku, Docker, Replit, etc
shardedClient: false // Use this if your using a sharded client {ShardingManager}
}
});
```

### [1.7.3](https://github.com/MaximKing1/BLWebhooks/compare/v1.7.2...v1.7.3) (2021-02-20)

* **Added:** Added typing for typescript
Expand Down
67 changes: 39 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
- [Vote Database](#vote-database)
- [Other Projects](#our-projects)

<<<<<<< HEAD
# Major Update! Read Changes [Here!](#WebhooksManager-Options-Updated)

=======
>>>>>>> parent of 0384dac (MASSIVE UPDATE)
# Installation

Need Any Help Setting It Up? Join Our [Support Server](https://discord.gg/8j4ZkpPvzP).
Expand Down Expand Up @@ -85,15 +88,7 @@ const discord = require("discord.js");
const client = discord.Client();
const { WebhooksManager } = require("blwebhooks");

const voteClient = WebhooksManager(client, 80, {
database: "mongoose", // mongoose or sqlite
extraLogging: true, // This will enable extraLogging {Debugging}
extra: {
extraProtection: true, // Leave Enabled Unless Using Small Amount Of RAM
proxyTrust: false, // Enable this if your behind a proxy, Heroku, Docker, Replit, etc
shardedClient: false // Use this if your using a sharded client
}
});
const voteClient = new WebhooksManager(client, 80);
client.voteManager = voteClient;
```

Expand All @@ -110,34 +105,50 @@ bot.on("ready", () => { // When the bot is ready

const { WebhooksManager } = require("blwebhooks");

const voteClient = WebhooksManager(bot, 80, {
database: "mongoose", // mongoose or sqlite
extraLogging: true, // This will enable extraLogging {Debugging}
extra: {
extraProtection: true, // Leave Enabled Unless Using Small Amount Of RAM
proxyTrust: false, // Enable this if your behind a proxy, Heroku, Docker, Replit, etc
shardedClient: false // Use this if your using a sharded client
}
});
const voteClient = new WebhooksManager(bot, 80);
bot.voteManager = voteClient;

bot.connect(); // Get the bot to connect to Discord
```

<<<<<<< HEAD
# WebhooksManager Options Updated
=======
**Vote's Storage**
>>>>>>> parent of 0384dac (MASSIVE UPDATE)
```js
const voteClient = WebhooksManager(client, 80, {
database: "mongoose", // mongoose or sqlite for vote logging
extraLogging: true, // This will enable extraLogging {Debugging}
extra: {
extraProtection: true, // Leave Enabled Unless Using Small Amount Of RAM
proxyTrust: false, // Enable this if your behind a proxy, Heroku, Docker, Replit, etc
shardedClient: false // Use this if your using a sharded client {ShardingManager}
}
});
// The DB can be set to either mongo, sqlite
// Only set the string if using the mongoose db
voteClient.setStroage(DB, String);

// MongooseDB Example (recommended)
voteClient.setStroage("mongo", "mongodb://localhost/my_database");

// SQLITE Example
voteClient.setStroage("sqlite");
```
For usage on pulling data see the [Database Vote](#database-vote) Section.

**Turn On Sharding Support**
```js
voteClient.shardedClient(true);
```

**Turn On Extended Security**
```js
// This will enable bruteforce protection for module, once enabled
// it will start the protection also using more CPU.
voteClient.extraProtection(true);
```

**Turn On Proxy Trust**
```js
// Enable this option is you use this behind a proxy like
// Heroku services etc
voteClient.proxyTrust(true);
```

**Emit Test Vote Event**
**Emit Test Vote Events**
```js
// Emit a test event to test your Voted Event
voteClient.testVote(userID, botID);
Expand Down
12 changes: 3 additions & 9 deletions examples/Botrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ const { WebhooksManager } = require("blwebhooks");

// Attatch The Client and Port to the module.
// The client is it attaching to the client, 80 is the port it will run on
const voteClient = WebhooksManager(client, 80, {
database: "mongoose", // mongoose or sqlite
extraLogging: true,
extra: {
extraProtection: true,
proxyTrust: true,
shardedClient: true
}
});
const voteClient = new WebhooksManager(client, 80);
client.voteManager = voteClient;

voteClient.extraProtection(true);

voteClient.BotrixVoteHook("Botrix", "LOADS_OF_RANDOMNESS", true);

// This code will run after a new vote was received from Botrix
Expand Down
12 changes: 3 additions & 9 deletions examples/InfinityBotList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ const { WebhooksManager } = require("blwebhooks");

// Attatch The Client and Port to the module.
// The client is it attaching to the client, 80 is the port it will run on
const voteClient = WebhooksManager(client, 80, {
database: "mongoose", // mongoose or sqlite
extraLogging: true,
extra: {
extraProtection: true,
proxyTrust: true,
shardedClient: true
}
});
const voteClient = new WebhooksManager(client, 80);
client.voteManager = voteClient;

voteClient.extraProtection(true);

voteClient.IBLVoteHook("IBLHook", "LOADS_OF_RANDOMNESS", true);

// This code will run after a new vote was received from InfinityBotList
Expand Down
12 changes: 3 additions & 9 deletions examples/VoidBots.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ const { WebhooksManager } = require("blwebhooks");

// Attatch The Client and Port to the module.
// The client is it attaching to the client, 80 is the port it will run on
const voteClient = WebhooksManager(client, 80, {
database: "mongoose", // mongoose or sqlite
extraLogging: true,
extra: {
extraProtection: true,
proxyTrust: true,
shardedClient: true
}
});
const voteClient = new WebhooksManager(client, 80);
client.voteManager = voteClient;

voteClient.extraProtection(true);

voteClient.VoidBotsVoteHook("VBHOOK", "LOADS_OF_RANDOMNESS", true);

// This code will run after a new vote was received from InfinityBotList
Expand Down
11 changes: 3 additions & 8 deletions examples/testConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ const client = discord.Client();

const { WebhooksManager } = require("blwebhooks");

const voteClient = WebhooksManager(client, 80, {
const manager = WebhooksManager(client, {
database: "mongoose", // mongoose or sqlite
extraLogging: true,
extra: {
extraProtection: true,
proxyTrust: true,
shardedClient: true
}
port: "80"
});
client.voteManager = voteClient;
client.voteManager = manager;
68 changes: 67 additions & 1 deletion src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ class WebhooksManager extends EventEmitter {
this.port = port;
/**
* The WebhooksManager Database
* @param {Manager.database}
* @param {client.ready}
*/
this.database = options.database;
<<<<<<< HEAD
/**
* Extra Logging
* @param {Manager.extraLogging}
Expand Down Expand Up @@ -119,6 +120,8 @@ class WebhooksManager extends EventEmitter {
else if (this.extraProtection == false) {
console.log(chalk.red("[BLWEBHOOKS] Extra protection disabled."));
}
=======
>>>>>>> parent of 0384dac (MASSIVE UPDATE)

if (!client) {
return console.log(chalk.red("[BLWEBHOOKS] The client is not defined"));
Expand All @@ -142,6 +145,69 @@ class WebhooksManager extends EventEmitter {
}
}

async shardedClient(toggle) {
if (toggle == true) {
console.log(chalk.green("[BLWEBHOOKS] Sharding client has been enabled."));
}
else if (toggle == false) {
console.log(chalk.red("[BLWEBHOOKS] Sharding client has been disabled."));
}
}

async setStroage(DB, string) {
if (DB == "mongo") {
console.log(chalk.yellow("[BLWEBHOOKS] Enabled mongoose database."));
await mongoose.connect(string, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true
});
}
else if(DB == "sqlite") {
var sqlite3 = require("sqlite3").verbose();
this.db = new sqlite3.Database("voteHooks.db", async (err) => {
if (err) {
console.error(chalk.red(err.message));
}
console.log(chalk.yellow("[BLWEBHOOKS] Enabled SQLITE database."));
console.log(chalk.yellow("[BLWEBHOOKS] Connected to the voteHooks.db database."));
});
} else if (DB == "mysql") {
console.log(chalk.yellow("[BLWEBHOOKS] Enabled MYSQL database."));
}
}

async setLogging(toggle) {
if (toggle == true) {
console.log(chalk.green("[BLWEBHOOKS] Advanced logging enabled."));
return app.use(errorhandler());
}
else if (toggle == false) {
console.log(chalk.red("[BLWEBHOOKS] Advance logging disabled"));
}
}

async extraProtection(toggle) {
if (toggle == true) {
console.log(chalk.green("[BLWEBHOOKS] Extra protection enabled."));
return app.use(helmet({ contentSecurityPolicy: false, permittedCrossDomainPolicies: false }));
}
else if (toggle == false) {
console.log(chalk.red("[BLWEBHOOKS] Extra protection disabled."));
}
}

async proxyTrust(toggle) {
if (toggle == true) {
console.log(chalk.green("[BLWEBHOOKS] Proxy trust enabled."));
return app.enable("trust proxy");
}
else if (toggle == false) {
console.log(chalk.red("[BLWEBHOOKS] Proxy trust disabled."));
}
} // Enable this if your behind a proxy, Heroku, Docker, Replit, etc

async testVote(userID, botID) {
const type = "test";
const List = "Test";
Expand Down

0 comments on commit 5a11520

Please sign in to comment.