Basic commands for the player (play, stop, pause) #1869
-
Hi. I migrated from an old discord music player to this because this one seems to be up-to-date. I'm honestly struggling on creating basic commands. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
hello @steph-lion, Discord Player performs audio player related actions via const { useQueue } = require('discord-player');
const queue = useQueue(interaction.guild.id);
if (!queue) {
// bot is not in a voice channel
}
if (!queue.currentTrack) {
// not playing any track
}
// toggle pause action
queue.node.pause();
queue.node.resume();
queue.node.setPaused(true/false);
const state = queue.node.isPaused();
return interaction.reply({ content: `Playback has been ${state ? 'paused' : 'resumed'}` }); |
Beta Was this translation helpful? Give feedback.
hello @steph-lion,
Discord Player performs audio player related actions via
queue.node
object, queue related actions viaqueue
, etc. Discord Player also has a concept calledhooks
which provide easy access to these objects. If you want to implement apause/resume
command for example, you can make the use ofuseTimeline
hook: