Bonjour,

Je voudrais savoir comment faire lire à mon bot plusieurs fichiers audios, ça fait 2 mois que je galère dessus mais je ne trouve pas de solution x(

Ce que je fais

J'ai tenté de faire ce code mais je ne trouve pas d'autres solutions -_-

const Discord = require("discord.js");

module.exports.run = async (client, message, args) => {
    var code_length = args[0].length;
    console.log(`Code != 6 : ${code_length != 6}`)
    if(code_length != 6) return message.reply('veuillez saisir un code à 6 lettres.')
    if(!message.member.voice.channel) return message.reply('vous devez être dans un salon vocal.')
    if(message.guild.me.voice.channel) return message.reply('je suis déjà dans un salon vocal.')
    message.member.voice.channel.join().then(connection => {console.log('Connexion Vocal Réussi !')}).catch(console.error)
    let serveur = (args.splice(1).join(' ') || 'Aucune serveur spécifiée');
[...]
    Discord.GuildMember.member.voice.channel.members.setMute(true)
    const dispatcher0 = connection.play(`./assets/sounds/code/start.mp3`)
    dispatcher0.on("end", end => {const dispatcher1 = connection.play(`./assets/sounds/code/${args[0].charAt(0)}.mp3`)})
    dispatcher1.on("end", end => {const dispatcher2 = connection.play(`./assets/sounds/code/${args[0].charAt(1)}.mp3`)})
    dispatcher2.on("end", end => {const dispatcher3 = connection.play(`./assets/sounds/code/${args[0].charAt(2)}.mp3`)})
    dispatcher3.on("end", end => {const dispatcher4 = connection.play(`./assets/sounds/code/${args[0].charAt(3)}.mp3`)})
    dispatcher4.on("end", end => {const dispatcher5 = connection.play(`./assets/sounds/code/${args[0].charAt(4)}.mp3`)})
    dispatcher5.on("end", end => {const dispatcher6 = connection.play(`./assets/sounds/code/${args[0].charAt(5)}.mp3`)})
    dispatcher6.on("end", end => voiceChannel.leave())
    };

Ce que je veux

Lire un code à 6 lettres dans un channel vocal, grâce à des fichiers locaux, dans l'ordre et 1 par 1.
Et pouvoir mute tous les utiliseurs du vocal sauf le bot pendant la lecture du code ^^

Ce que j'obtiens

Erreur que j'ai quand je veux mute :

(node:15932) UnhandledPromiseRejectionWarning: ReferenceError: member is not defined
    at Object.module.exports.run (F:\Bot Discord\Among_Us\commands\general\code.js:17:5)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:15932) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15932) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Erreur lors de la lecture du code à 6 lettres (En retirant la ligne qui permet de mute):

(node:15832) UnhandledPromiseRejectionWarning: ReferenceError: connection is not defined
    at Object.module.exports.run (F:\Bot Discord\Among_Us\commands\general\code.js:17:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:15832) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15832) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Aucune réponse