Halfbroken fixes
This commit is contained in:
@@ -1,58 +1,58 @@
|
||||
const { getMusicStream } = require('./utils/getMusicStream');
|
||||
|
||||
class MusicQueue {
|
||||
constructor() {
|
||||
this.queue = new Map();
|
||||
this.looping = new Map();
|
||||
}
|
||||
constructor() {
|
||||
this.queue = new Map();
|
||||
this.looping = new Map();
|
||||
}
|
||||
|
||||
addToQueue(guildId, song) {
|
||||
if (!this.queue.has(guildId)) {
|
||||
this.queue.set(guildId, []);
|
||||
}
|
||||
addToQueue(guildId, song) {
|
||||
if (!this.queue.has(guildId)) {
|
||||
this.queue.set(guildId, []);
|
||||
}
|
||||
|
||||
this.queue.get(guildId).push(song);
|
||||
}
|
||||
this.queue.get(guildId).push(song);
|
||||
}
|
||||
|
||||
async removeFromQueue(guildId) {
|
||||
if (!this.queue.has(guildId)) {
|
||||
return;
|
||||
}
|
||||
async removeFromQueue(guildId) {
|
||||
if (!this.queue.has(guildId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const serverQueue = this.queue.get(guildId);
|
||||
const serverQueue = this.queue.get(guildId);
|
||||
|
||||
if (this.looping.has(guildId) && this.looping.get(guildId)) {
|
||||
const song = serverQueue.shift();
|
||||
const newSong = await getMusicStream(song.userInput);
|
||||
serverQueue.push(newSong);
|
||||
} else {
|
||||
serverQueue.shift();
|
||||
}
|
||||
}
|
||||
if (this.looping.has(guildId) && this.looping.get(guildId)) {
|
||||
const song = serverQueue.shift();
|
||||
const newSong = await getMusicStream(song.userInput);
|
||||
serverQueue.push(newSong);
|
||||
} else {
|
||||
serverQueue.shift();
|
||||
}
|
||||
}
|
||||
|
||||
getQueue(guildId) {
|
||||
if (!this.queue.has(guildId)) {
|
||||
return [];
|
||||
}
|
||||
getQueue(guildId) {
|
||||
if (!this.queue.has(guildId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return this.queue.get(guildId);
|
||||
}
|
||||
return this.queue.get(guildId);
|
||||
}
|
||||
|
||||
enableLooping(guildId) {
|
||||
this.looping.set(guildId, true);
|
||||
}
|
||||
enableLooping(guildId) {
|
||||
this.looping.set(guildId, true);
|
||||
}
|
||||
|
||||
disableLooping(guildId) {
|
||||
this.looping.set(guildId, false);
|
||||
}
|
||||
disableLooping(guildId) {
|
||||
this.looping.set(guildId, false);
|
||||
}
|
||||
|
||||
clearQueue(guildId) {
|
||||
if (!this.queue.has(guildId)) {
|
||||
return;
|
||||
}
|
||||
clearQueue(guildId) {
|
||||
if (!this.queue.has(guildId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.queue.set(guildId, []);
|
||||
}
|
||||
this.queue.set(guildId, []);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new MusicQueue();
|
||||
Reference in New Issue
Block a user