Coder Social home page Coder Social logo

shardbot-discord.js's Introduction

ShardBot-discord.js

A short example to set up the shards on your discord bot ! ๐Ÿ“

Are you trying to understand shards ? This code is for you !

Well, let's start by downloading the code. Go to the the file config.json. For the bot to be able to start, please complete the token :

{
    "token": "XXX"
}

Don't forget to configure this with your server's webhook id and password in bot.js :

client.statusHook = new Discord.WebhookClient("ID", "PASSWORD")

๐Ÿ”” Launch

To install discord.js :

npm i discord.js

To launch the bot with the sharder file :

#With Node
node sharder.js

#With pm2
pm2 start sharder.js --name "ShardBot"

๐Ÿ“Š Explanations

The shard is imposed by discord if your bot exceeds 2500 servers. Below it is not imposed. The goal of the shard is to launch the bot on the different servers but to be able to manage these servers.

Setting the scene :

  • Shard 1 > 500 servers
  • Shard 2 > 800 servers

If the bot shuts down on shard 1 it will no longer respond on the 500 servers it contains. But if i go to a shard 2 server the bot will respond.

To add more shards :

#Example to get two shards
manager.spawn(2)

#Example to get fives shards
manager.spawn(5)

๐Ÿ‘‘ Information

You can also get information about your different shards, more information about the documentation right here.

Example to get the ping of each shard :

const results = await this.client.shard.broadcastEval(() => {
    return [
        this.shard.ids[0],
        Math.round(this.ws.ping),
    ];
});

If you have any further questions, do not hesitate to open a issue !

shardbot-discord.js's People

Contributors

zeriodev avatar hideakiatsuyo 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.