Queue
Constructorโ
- Queue : options
Table of contentsโ
| Properties | Methods |
|---|---|
| current | add() |
| guildId | clear() |
| manager | duration() |
| previous | remove() |
| roundRobinShuffle() | |
| shuffle() | |
| size() | |
| totalSize() | |
| userBlockShuffle() |
Propertiesโ
currentโ
The current track
guildIdโ
The guild ID property.
managerโ
The Manager instance.
Return:
Manager
previousโ
The previous track
Methodsโ
add(track, offset)โ
Adds a track to the queue.
Return: void
Parameter Type Description Optional tracktrack{}|track{}[]The track or tracks to add. Can be a single Trackor an array ofTracks.offsetnumber The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
clear()โ
Clears the queue.
This will remove all tracks from the queue and emit a state update event.Return: void
duration()โ
The total duration of the queue in milliseconds.
This includes the duration of the currently playing track.Return: number
remove(start | position, end)โ
Removes track(s) from the queue.
Return:
track{}[]
- Remove track with position
- Remove tracks with range of positions
- Remove track with start or position and/or end
| Parameter | Type | Description | Optional |
|---|---|---|---|
position | number | If a single number is provided, it will be treated as the position of the track to remove. |
const { Manager } = require('magmastream');
const manager = new Manager({
...ManagerOptions
})
const searchResponse = await manager.search('Never Gonna Give You Up');
const player = client.lavalink.create({
...PlayerOptions
});
player.connect()
player.queue.add(searchResponse.tracks);
player.play();
setTimeout(() => {
player.queue.remove(2)
}, 5000);
| Parameter | Type | Description | Optional |
|---|---|---|---|
start | number | Position for start range to remove | |
end | number | Position for end range to remove |
const { Manager } = require('magmastream');
const manager = new Manager({
...ManagerOptions
})
const searchResponse = await manager.search('Never Gonna Give You Up');
const player = client.lavalink.create({
...PlayerOptions
});
player.connect()
player.queue.add(searchResponse.tracks);
player.play();
setTimeout(() => {
player.queue.remove(2, 5)
}, 5000);
| Parameter | Type | Description | Optional |
|---|---|---|---|
startOrPosition | number | If a single number is provided, it will be treated as the position of the track to remove. If two numbers are provided, they will be used as the start and end of a range of tracks to remove. | |
end | number | Optional, end of the range of tracks to remove. |
const { Manager } = require('magmastream');
const manager = new Manager({
...ManagerOptions
})
const searchResponse = await manager.search('Never Gonna Give You Up');
const player = client.lavalink.create({
...PlayerOptions
});
player.connect()
player.queue.add(searchResponse.tracks);
player.play();
setTimeout(() => {
// remove track at position 2
player.queue.remove(2)
// or
// remove tracks from position 2 to 5
player.queue.remove(2, 5)
}, 5000);
roundRobinShuffle()โ
Shuffles the queue to play tracks requested by each user one by one.
Return: void
shuffle()โ
Shuffles the queue.
This will randomize the order of the tracks in the queue and emit a state update event.Return: void
size()โ
The size of tracks in the queue.
This does not include the currently playing track.Return: number
totalSize()โ
The total size of tracks in the queue including the current track.
This includes the current track if it is not null.Return: number
userBlockShuffle()โ
Shuffles the queue to play tracks requested by each user one block at a time.
Return: void