#Shards Interaction

4 messages · Page 1 of 1 (latest)

humble yoke
#

Hello !
I have some troubles with sharding specifically with interactions between shards, i wonder if it's possible to send a message with buttons to a server present on an other shard and then get the interaction response ?
I know .broadcastEval() exist but the data are serialized so it's not really the solution...

discord.js version : 13.7.0
node version : 16.14.2

trim trail
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

orchid spire
humble yoke
#

I've done something like this:

const Embed = new MessageEmbed()
    .setDescription('testing shards broadcastEval')

const Buttons = new MessageActionRow()
.addComponents(
new MessageButton()
    .setCustomId('buttonid')
    .setEmoji('❗')
    .setStyle('SECONDARY'),
)

const msg = await bot.shard.broadcastEval(async (c, embed, buttons) => {
    const channel = await c.channels.cache.get('id');
    if (channel) {
        let m = await channel.send({ embeds: [embed.embed[0]], components: embed.buttons })
        const collector = m.createMessageComponentCollector({ time: 30000 })

        collector.on('collect', async(i) => {
            console.log('user interacted')
        })
    }
}, { context: { embed: [Embed], buttons: [Buttons] } })

But now if i want to send an other embed from the interaction do i really need to define MessageEmbed again ?


const msg = await bot.shard.broadcastEval(async (c, embed, buttons) => {
    const { MessageEmbed } = require('discord.js') // Do i really need to add this for every discord.js functionnality ?
    const channel = await c.channels.cache.get('id');
    if (channel) {
        let m = await channel.send({ embeds: [embed.embed[0]], components: embed.buttons })
        const collector = m.createMessageComponentCollector({ time: 30000 })

        collector.on('collect', async(i) => {
            switch(i.id) {
                case 'buttonid':
                    const embed2 = new MessageEmbed()
                        .setDescription('another embed')
                    i.reply({ embeds: [embed2] })
                    break
            }
        })
    }
}, { context: { embed: [Embed], buttons: [Buttons] } })