简体   繁体   中英

How does AutoShardedBot work in discord.py?

Would someone explain how sharding works, specifically discord.ext.commands.AutoShardedBot ? I put multiple questions below:

  • Does it run on multiple servers?
  • If not, how is it beneficial to shard it?
  • Do guilds sometimes switch between shards?
  • How do I use one database if the bot runs on multiple servers?

Thanks for your time.

  1. If by "multiple servers" you mean physical machines, no, it's a single python instance.
  2. Discord requires sharding past 2.5k guilds.
  3. Guilds are assigned to shard by (guild_id >> 22) % shard_count
  4. Make the database accessible over the network, be sure to secure it with a strong password, connect to it from each.

if you need to split it to multiple machines, you can pass shard_id and shard_count to a normal Bot instance.

Discord Docs on Sharding

Would someone explain how sharding works, specifically discord.ext.commands.AutoShardedBot ? I put multiple questions below:

  • Does it run on multiple servers?
  • If not, how is it beneficial to shard it?
  • Do guilds sometimes switch between shards?
  • How do I use one database if the bot runs on multiple servers?

Thanks for your time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM