Send a message in many channels? Discord.jsv14

35 Views Asked by At

i want to do a bump command but the script don't work, i ask a request to my database and i get all the channels in the database but it don't send the bump in every channels of the database, only the last who was registered. Here is my script :

module.exports = { name: "bump", description: "Bumper le serveur", permission: "Aucune", dm: false, category: "Utile", options: [],

 async run(bot, message, args, db) {

    db.query(`SELECT channel FROM bump`, async (err, req) => {
        const serverId = message.guild.id

        const server = bot.guilds.cache.get(serverId);

        const invite = await server.channels.cache.random().createInvite();

        const invitation = invite
        
     const Embed = new Discord.EmbedBuilder()
     .setTitle("Nouveau BUMP")
     .setDescription(`Serveur : [${message.guild}](${invitation})\n\n Bump effectué par ${message.user}\n\n`)
     .setColor(bot.color)
     .setTimestamp()
     .setImage("https://media.discordapp.net/attachments/1146418720231657626/1165693873281048576/image.png?ex=6547c804&is=65355304&hm=6fddf137ab4bc5736eff7bbf29ae6fb39432f182c81c94d8a388de9f1b94dba7&=&width=931&height=288")

        const channelsend = req.channel     
        const salonDestination = bot.channels.cache.get(channelsend)
        await salonDestination.send(`${invitation}`)
        await salonDestination.send({embeds: [Embed]})
        await message.reply({content: `**Bump envoyé avec succès.** `, ephemeral: true})
                })
            }

}

I tried to change my sql request but it didnt worked

0

There are 0 best solutions below