Essentially, a slash command is utilized to initiate playing a music video in Distube. It plays for approximately 30 seconds and then abruptly stops, even though the queue indicates that the music is still playing. There are no errors appearing in my terminal or any related logs.
I am uncertain about what specifics to provide, so please inform me accordingly.
index.js
const distube = require("distube")
const Distube = new distube.DisTube(Client, {
emitNewSongOnly: true,
leaveOnStop:false,
leaveOnFinish: false,
updateYouTubeDL: true,
nsfw: true,
plugins:[new SpotifyPlugin()],
youtubeCookie:"COOKIE"
})
play.js
module.exports = {
data:{name:"play",description:"Play music",options:[{name:"query",description:"Get song name",type:"STRING",required:true}]},
async execute(utils,Client,i,Discord,userModel,serverModel,banModel,Distube){
if(!i.member.voice.channel)return i.reply({content:'Please join a voice channel',ephemeral:true})
if(!i.guild.members.me.voice.channel == i.member.voice.channel)return i.reply({content:'We are not in the same voice channel',ephemeral:true})
const song = i.options.getString("query")
Distube.play(i.member.voice.channel, song, {member:i.member,textChannel:i.channel})
i.reply({content:"Starting...",ephemeral:true})
}
}
addSong.js
const {Distube} = require("../index")
const Discord = require("discord.js")
const utils = require("../utils/utils")
Distube.on("addSong", (queue,song) => {
queue.textChannel.send({
embeds:[
new Discord.MessageEmbed()
.setAuthor({name:`Added by ${song.user.username}`,iconURL:song.user.avatarURL()})
.setTitle(song.name)
.setThumbnail(song.thumbnail)
.setURL(song.url)
.addFields([
{
name: '**Likes | Views**',
value: `**${utils.roundNumber(song.likes)} | ${utils.roundNumber(song.views)}**`,
inline: true
},
{
name:"**Duration | Position**",
value:`**${song.formattedDuration} | ${queue.songs.length}**`,
inline: true
}
])
.setFooter({text:`Volume: ${queue.volume}% | Loop: ${queue.repeatMode ? queue.repeatMode == 2 ? "All Queue" : "This Song" : "Off"}`})
]
})
})
Discord.js 13.15.0 Distube 3.3.4 Node 18.14.2
UPDATE
To address this issue Upgrade to the most recent version of distube