简体   繁体   English

如何在 discord.py 中分片 Discord 机器人?

[英]How can I shard a Discord bot in discord.py?

I've been looking everywhere from the past few days and I can't really figure out how I could implement sharding in a discord bot.过去几天我一直在四处寻找,但我真的不知道如何在不和谐的机器人中实现分片。 I have tried looking in the documentation but couldn't find anything that would explain how to implement it.我曾尝试查看文档,但找不到任何可以解释如何实现它的内容。

I'm using discord.py by the way顺便说一下,我正在使用 discord.py

Instead of a normal client, you should create an AutoShardedClient() :您应该创建一个AutoShardedClient()代替普通客户端:

client = discord.AutoShardedClient(shard_count=10)

See the relevant documentation .请参阅相关文档

就像@Bharel 写的一样,将您的普通客户端更改为AutoShardedClient() ,但我建议使用它:

client = commands.AutoShardedBot(shard_count=10, command_prefix="??") #with this you can easily choose one prefix for all bots that were sharded

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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