2021-11-21 20:23:25 +00:00
import { queues } from "../../utils/soundplayer.js" ;
import MusicCommand from "../../classes/musicCommand.js" ;
class RemoveCommand extends MusicCommand {
async run ( ) {
2022-09-01 01:00:34 +00:00
this . success = false ;
2022-03-31 05:42:03 +00:00
if ( ! this . channel . guild ) return "This command only works in servers!" ;
2022-04-05 03:05:28 +00:00
if ( ! this . member . voiceState . channelID ) return "You need to be in a voice channel first!" ;
2022-03-31 05:42:03 +00:00
if ( ! this . channel . guild . members . get ( this . client . user . id ) . voiceState . channelID ) return "I'm not in a voice channel!" ;
2022-08-27 01:55:24 +00:00
if ( this . connection . host !== this . author . id && ! process . env . OWNER . split ( "," ) . includes ( this . connection . host ) ) return "Only the current voice session host can remove songs from the queue!" ;
2022-06-07 23:26:40 +00:00
const pos = parseInt ( this . options . position ? ? this . args [ 0 ] ) ;
2021-11-21 20:23:25 +00:00
if ( isNaN ( pos ) || pos > this . queue . length || pos < 1 ) return "That's not a valid position!" ;
const removed = this . queue . splice ( pos , 1 ) ;
2022-06-14 05:38:01 +00:00
if ( removed . length === 0 ) return "That's not a valid position!" ;
const track = await this . connection . player . node . rest . decode ( removed [ 0 ] ) ;
2022-03-31 05:42:03 +00:00
queues . set ( this . channel . guild . id , this . queue ) ;
2022-09-01 01:00:34 +00:00
this . success = true ;
2022-01-15 05:26:38 +00:00
return ` 🔊 The song \` ${ track . title ? track . title : "(blank)" } \` has been removed from the queue. ` ;
2021-11-21 20:23:25 +00:00
}
2022-04-05 03:05:28 +00:00
static flags = [ {
name : "position" ,
type : 4 ,
description : "The queue position you want to remove" ,
min _value : 1 ,
required : true
} ] ;
2021-11-21 20:23:25 +00:00
static description = "Removes a song from the queue" ;
static aliases = [ "rm" ] ;
}
2021-12-13 22:09:12 +00:00
export default RemoveCommand ;