Giter Club home page Giter Club logo

testtest's Introduction

DBM Mods Bot Sharding

Allows your bot created by Discord Bot Maker to take advantage of sharding!

Installation

Download the ZIP and extract the files to your Bot Base Folder.

Your Bot folder should look like this:

shard

Running

Once those are in the folder, up at the top where the path is, select everything in there and type cmd and press enter: cmd

In the command window that opens, type node sharded-bot.js node

If you want to run it with a linux terminal then instead of running it with bot node.js you run it node sharded-bot.js

Example RawData

Command [prefix]shardinfo

{
  "name": "shardinfo",
  "permissions": "NONE",
  "restriction": "1",
  "_id": "XRenR",
  "actions": [
    {
      "behavior": "1",
      "interpretation": "0",
      "code": "client.shard && client.shard.fetchClientValues('users.size')\n.then(results => {\n    var output = results.reduce(function(accumulator, currentValue){\n      return accumulator + currentValue;\n    });\n    this.storeValue(output, 1 ,\"totalUsers\", cache)\n    this.callNextAction(cache)\n}).catch(console.error);",
      "storage": "0",
      "varName": "",
      "name": "Run Script"
    },
    {
      "behavior": "1",
      "interpretation": "0",
      "code": "client.shard && client.shard.fetchClientValues('guilds.size')\n.then(results => {\n    var output = results.reduce(function(accumulator, currentValue){\n      return accumulator + currentValue;\n    });\n    this.storeValue(output, 1 ,\"totalGuilds\", cache)\n    this.callNextAction(cache)\n}).catch(console.error);",
      "storage": "0",
      "varName": "",
      "name": "Run Script"
    },
    {
      "channel": "0",
      "varName": "",
      "message": "There are a total of ${tempVars(\"totalUsers\")} users in \n${tempVars(\"totalGuilds\")} guilds across all shards.\n\nThis command was ran in shard ${(client.shard.id + 1)} and has an id \nof ${(client.shard.id)}.\n\n\nTotal Active Shards: ${client.shard.count}\n",
      "storage": "0",
      "varName2": "",
      "name": "Send Message"
    }
  ]
}

Run Scripts

The command above uses these scripts.

Make sure End Behavior is set to Do Not Call Next Action, and Evaluate Text First is selected for interpretation style for all of these scripts

Total Amount Of Users

This script will store all users to a temp variable called totalUsers, There are a total of ${tempVars("totalUsers")} users

client.shard.fetchClientValues('users.size')
.then(results => {
    var output = results.reduce(function(accumulator, currentValue){
      return accumulator + currentValue;
    });
    this.storeValue(output, 1 ,"totalUsers", cache)
    this.callNextAction(cache)
}).catch(console.error);

Total Amount Of Guilds

This script will store all users to a temp variable called totalGuilds, users in ${tempVars("totalGuilds")} guilds

client.shard.fetchClientValues('guilds.size')
.then(results => {
    var output = results.reduce(function(accumulator, currentValue){
      return accumulator + currentValue;
    });
    this.storeValue(output, 1 ,"totalGuilds", cache)
    this.callNextAction(cache)
}).catch(console.error);

If you want to do anything across shards. You will need to use client.shard.broadCastEval()

Sorry there currently isn't a Run Script or a Raw Data command to test this with.

Please read the API docs!

testtest's People

Contributors

kla123101k avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.