Started sharding: a lot of `unknown interactions`

I'v seen a consitant increase in unknown interaction since I started shardig (was barely getting any when it wasnt sharded).
My bot works mainly through Dms, which by default are all handled by shard 0 (so there is no need to communicate between shards). I do still get unknown interaction from dms buttons tho (like 1 out of 20).
I dunno what I could be possibly doing wrong since the code barely changed from before sharding to now.
And the first thing I try to do asap is to defer such interaction anyway

ShardingManager:
const { ShardingManager, ShardClientUtil } = require('discord.js');
const manager = new ShardingManager('/home/ubuntu/discord/index.js', {
    token: token,
    totalShards: Number(totalShards),  // Total number of shards you want to run
    shardList: [0,1,2,3,4], 
    respawn: true,  // Automatically respawn shards if they crash
});

//manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));

manager.on('shardCreate', (shard) => {
    console.log(`Shard ${shard.id} created.`);
   
    // Listen for messages from this shard
    shard.on('message', (message) => {
        console.log(`Message from shard ${shard.id}:`);
        const targetShard = manager.shards.get(message.shardId);
        if (targetShard) {
            targetShard.send(message)
                .then(() => {
                    console.log(`Message successfully sent to shard ${message.shardId}.`);
                })
                .catch((error) => {
                    console.error(`Failed to send message to shard ${message.shardId}:`, error);
                });
        } else {
            console.error(`Shard ${message.shardId} not available.`);
        }
    });
});

manager.broadcast({ action: 'log', message: 'A global event occurred.' });
manager.spawn();
Was this page helpful?