简体   繁体   中英

No longer reacting after moving a text

I changed my text today from a normal text to a variable in order to have access to localization for multiple language Now, when the text is displayed it no longer also react with the emote and i have no clue why, because i only changed the text

Old code:

                if (!store.inQuiz) {
                message.channel.send("Processing audio, when it's done you can use !seek [timestamp]")
                    .then(function (message) {
                        new ffmpeg({
                                source: (ytdl(currentSongObj.link, {
                                    highWaterMark: 1 << 25,
                                    filter: 'audioonly',
                                    quality: 'lowestaudio'
                                })),
                                nolog: true
                            })
                            .on('end', () => {
                                try {
                                    store.statusProc = true;
                                } catch {}
                                message.react('✅')
                            })
                            .on('error', (err) => {
                                console.log('an FFMPEG error happened: ' + err.message);
                                skipSong(THIS_)
                                return;
                            })
                            .saveToFile('./root/DiscordMusicGiveawayBotNew/music/' + message.guild.id + '.mp3');
                    })
            }

Vs new code:

            if (!store.inQuiz) {
                getLanguageMessage(message.guild.id, "audioProcess").then((returnedText) => {
                    message.channel.send(returnedText);
                })
                    .then(function (message) {
                        new ffmpeg({
                                source: (ytdl(currentSongObj.link, {
                                    highWaterMark: 1 << 25,
                                    filter: 'audioonly',
                                    quality: 'lowestaudio'
                                })),
                                nolog: true
                            })
                            .on('end', () => {
                                try {
                                    store.statusProc = true;
                                } catch {}
                                message.react('✅')
                            })
                            .on('error', (err) => {
                                console.log('an FFMPEG error happened: ' + err.message);
                                skipSong(THIS_)
                                return;
                            })
                            .saveToFile('./root/DiscordMusicGiveawayBotNew/music/' + message.guild.id + '.mp3');
                    })
            }

What i did wrong and why right now it does no longe react also at message

getLanguageMessage should return message.channel.send

So simply remove the curly brackets

getLanguageMessage(message.guild.id, "audioProcess").then((returnedText) => message.channel.send(returnedText))

The full code should be

if (!store.inQuiz) {                 
    getLanguageMessage(message.guild.id, "audioProcess").then((returnedText) => message.channel.send(returnedText))
                .then(function (message) {
                    new ffmpeg({
                            source: (ytdl(currentSongObj.link, {
                                highWaterMark: 1 << 25,
                                filter: 'audioonly',
                                quality: 'lowestaudio'
                            })),
                            nolog: true
                        })
                        .on('end', () => {
                            try {
                                store.statusProc = true;
                            } catch {}
                            message.react('✅')
                        })
                        .on('error', (err) => {
                            console.log('an FFMPEG error happened: ' + err.message);
                            skipSong(THIS_)
                            return;
                        })
                        .saveToFile('./root/DiscordMusicGiveawayBotNew/music/' + message.guild.id + '.mp3');
                })
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM