(he started to give himself this error)

Error: This session would have handled too many guilds - Sharding is required.

at WebSocketConnection.client.ws.connection.once.event (/rbd/pnpm-volume/dde64ec6-8a65-458a-9c99-0276aac68c86/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/ClientManager.js:50:41)

at Object.onceWrapper (events.js:315:30)

at emitOne (events.js:116:13)

at WebSocketConnection.emit (events.js:211:7)

at WebSocketConnection.onClose (/rbd/pnpm-volume/dde64ec6-8a65-458a-9c99-0276aac68c86/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:390:10)

at WebSocket.onClose (/rbd/pnpm-volume/dde64ec6-8a65-458a-9c99-0276aac68c86/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/event-target.js:124:16)

at emitTwo (events.js:126:13)

at WebSocket.emit (events.js:214:7)

at _receiver.cleanup (/rbd/pnpm-volume/dde64ec6-8a65-458a-9c99-0276aac68c86/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/websocket.js:220:12)

at Receiver.cleanup (/rbd/pnpm-volume/dde64ec6-8a65-458a-9c99-0276aac68c86/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/receiver.js:535:15)

(node:19589) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit

@cross

Can you tell me your discord so I can show you how to do sharding for your discord bot, and once we get it 100% working, I will post the solution here for others to use if they ever encounter the same error!

Merhaba! Öncelikle şunu bilmelisin ki discord.js güçlü bir lib olmasına rağmen sınırları vardır, hatanın sebebi çok fazla oluşturulan EventEmitters(client.on('message'...) gibi gibi) dinleyicilerinin yorulması ve aşırı yüklenmesidir.

Bunu düzeltmenin iki farklı yolu var;

  • Listener’larınızı azaltıp kodunuzu optimize etmelisiniz
    yada
  • emitter.setMaxListeners() fonksiyonu ile Listener’larınızın sayısını arttırabilirsiniz.

İyi kodlamalar!