0
votes

So I recently updated my bot so it uses shards now but I'm coming across a problem where I can't react to a message as the emote isn't on the same shard and I don't know how to get it from a different shard.

let msg = await message.channel.send("hey")

async function reactEmoji(emote){
  msg.react(emote)
}

client.shard.broadcastEval(`
 let emote = this.emojis.cache.get("emoji id")
 if(emote){
  (${reactEmoji}).call(this, emote)
 }
`);

So the code above is what I've already tried doing but it seems to not work, when I try to react to the message it says msg is undefined and I also tried to pass the msg with emote which didn't work either.

The other way I tried to do was reacting to a message using the emojis ID:

msg.react("emoji id")

This again had the same problem as the emoji wasn't on the same shard.

So if anyone knows a good way to do this let me know please :)

2

2 Answers

1
votes

You should probably use this promise (it should work i think):

let emoji = await client.shard.broadcastEval(`
            (async () => {
                const emoji = this.emojis.cache.get('emoji ID')
                if (emoji) {
                    return emoji
                    true;
                } else {
                    false;
                }
            })();
        `)

let msg = await message.channel.send("hey")
msg.react(emoji)
1
votes

Find a tutorial just here!

It explains how to build a function for shards and specifically how to get an emote from another shard.