how i can use custom queue

how i can use custom queue
45 Replies
MEE6
MEE6•2y ago
GG @Ghos't, you just advanced to level 2!
1Lucas1.apk
1Lucas1.apk•2y ago
const { MoonlinkDatabase } = require('./MoonlinkDatabase');
const { MoonlinkManager } = require('../@Moonlink/MoonlinkManager');
const { MoonlinkTrack } = require('./MoonlinkTrack');

class CustomMoonlinkQueue {
constructor(manager, data) {
this.db = new MoonlinkDatabase();
this.guildId = data.guildId;
this.manager = manager;
this.clientId = manager.clientId; // Obtendo o clientId do MoonlinkManager
}

add(data, position) {
if (!data) throw new Error('[ @Moonlink/Queue ]: "data" option is empty');
let queue = this.db.get(`${this.clientId}.queue.${this.guildId}`);
if (typeof position !== 'undefined' && (position < 1 || position > queue.length + 1)) {
throw new Error('[ @Moonlink/Queue ]: Invalid position specified');
}
if (typeof position === 'undefined' || position > queue.length + 1) {
if (Array.isArray(queue)) {
this.db.push(`${this.clientId}.queue.${this.guildId}`, data);
} else if (queue && queue.length > 0 && queue[0]) {
queue = [queue, data];
this.db.set(`${this.clientId}.queue.${this.guildId}`, queue);
} else {
this.db.push(`${this.clientId}.queue.${this.guildId}`, data);
}
} else {
queue.splice(position - 1, 0, data);
this.db.set(`${this.clientId}.queue.${this.guildId}`, queue);
}
}

first() {
let queue = this.db.get(`${this.clientId}.queue.${this.guildId}`) || null;
if (!queue) return null;
if (Array.isArray(queue)) {
return queue[0];
} else if (queue && queue.length > 0 && queue[0]) return queue;
else return queue[0];
}

clear() {
let queue = this.db.get(`${this.clientId}.queue.${this.guildId}`) || null;
if (!queue) return false;
this.db.delete(`${this.clientId}.queue.${this.guildId}`);
return true;
}
const { MoonlinkDatabase } = require('./MoonlinkDatabase');
const { MoonlinkManager } = require('../@Moonlink/MoonlinkManager');
const { MoonlinkTrack } = require('./MoonlinkTrack');

class CustomMoonlinkQueue {
constructor(manager, data) {
this.db = new MoonlinkDatabase();
this.guildId = data.guildId;
this.manager = manager;
this.clientId = manager.clientId; // Obtendo o clientId do MoonlinkManager
}

add(data, position) {
if (!data) throw new Error('[ @Moonlink/Queue ]: "data" option is empty');
let queue = this.db.get(`${this.clientId}.queue.${this.guildId}`);
if (typeof position !== 'undefined' && (position < 1 || position > queue.length + 1)) {
throw new Error('[ @Moonlink/Queue ]: Invalid position specified');
}
if (typeof position === 'undefined' || position > queue.length + 1) {
if (Array.isArray(queue)) {
this.db.push(`${this.clientId}.queue.${this.guildId}`, data);
} else if (queue && queue.length > 0 && queue[0]) {
queue = [queue, data];
this.db.set(`${this.clientId}.queue.${this.guildId}`, queue);
} else {
this.db.push(`${this.clientId}.queue.${this.guildId}`, data);
}
} else {
queue.splice(position - 1, 0, data);
this.db.set(`${this.clientId}.queue.${this.guildId}`, queue);
}
}

first() {
let queue = this.db.get(`${this.clientId}.queue.${this.guildId}`) || null;
if (!queue) return null;
if (Array.isArray(queue)) {
return queue[0];
} else if (queue && queue.length > 0 && queue[0]) return queue;
else return queue[0];
}

clear() {
let queue = this.db.get(`${this.clientId}.queue.${this.guildId}`) || null;
if (!queue) return false;
this.db.delete(`${this.clientId}.queue.${this.guildId}`);
return true;
}
get size() {
return this.db.get(`${this.clientId}.queue.${this.guildId}`)
? this.db.get(`${this.clientId}.queue.${this.guildId}`).length
: 0;
}

remove(position) {
if (!position && typeof position !== "number")
throw new Error('[ @Moonlink/Queue ]: option "position" is empty or different from number');
if (!this.size) throw new Error("[ @Moonlink/Queue ]: the queue is empty");
let queue = this.db.get(`${this.clientId}.queue.${this.guildId}`);
if (!queue[position - 1])
throw new Error("[ @Moonlink/Queue ]: indicated position is undefined");
queue.splice(position - 1, 1);
this.db.set(`${this.clientId}.queue.${this.guildId}`, queue);
return true;
}

get all() {
return this.db.get(`${this.clientId}.queue.${this.guildId}`)
? this.db.get(`${this.clientId}.queue.${this.guildId}`)
: null;
}
}

module.exports = CustomMoonlinkQueue;
get size() {
return this.db.get(`${this.clientId}.queue.${this.guildId}`)
? this.db.get(`${this.clientId}.queue.${this.guildId}`).length
: 0;
}

remove(position) {
if (!position && typeof position !== "number")
throw new Error('[ @Moonlink/Queue ]: option "position" is empty or different from number');
if (!this.size) throw new Error("[ @Moonlink/Queue ]: the queue is empty");
let queue = this.db.get(`${this.clientId}.queue.${this.guildId}`);
if (!queue[position - 1])
throw new Error("[ @Moonlink/Queue ]: indicated position is undefined");
queue.splice(position - 1, 1);
this.db.set(`${this.clientId}.queue.${this.guildId}`, queue);
return true;
}

get all() {
return this.db.get(`${this.clientId}.queue.${this.guildId}`)
? this.db.get(`${this.clientId}.queue.${this.guildId}`)
: null;
}
}

module.exports = CustomMoonlinkQueue;
It won't work correctly, I forgot that a lot of things use database inside the package, I think the right thing would be to do everything customized In the next few days I will try to remove most of the parts where the database is used outside
1Lucas1.apk
1Lucas1.apk•2y ago
I located all the parts where database is used outside the queue
afraid-scarlet
afraid-scarletOP•2y ago
@1Lucas1.apk didu fix it ? @1Lucas1.apk when i use custom queue the pause not working and return true
1Lucas1.apk
1Lucas1.apk•2y ago
When you use the default queue, what error does using multiple bots cause? @Ghos't
afraid-scarlet
afraid-scarletOP•2y ago
Other bots start using a single queue so there won't be a dedicated queue for each bot but I don't have this problem with distube
1Lucas1.apk
1Lucas1.apk•2y ago
Eu acho que podemos contonar fazendo uma coisa Vou voltar daqui a pouco I spoke in Portuguese, I'll be back in a little while, I already know what to do to get around this
afraid-scarlet
afraid-scarletOP•2y ago
No problem, I will translate it take your time
1Lucas1.apk
1Lucas1.apk•2y ago
@Ghos't you don't need to use the custom queue, delete that part there, and use the default that I changed the way it stores the data, it will separate a json for each clientId :), Have a great day, download the new version for apply this change I tested it and it's working correctly
afraid-scarlet
afraid-scarletOP•2y ago
thanks man You are the best
afraid-scarlet
afraid-scarletOP•2y ago
No description
afraid-scarlet
afraid-scarletOP•2y ago
@1Lucas1.apk
1Lucas1.apk
1Lucas1.apk•2y ago
Did the error appear again?
afraid-scarlet
afraid-scarletOP•2y ago
yes and pause not working idk why queue.pause()
1Lucas1.apk
1Lucas1.apk•2y ago
I was trying to see the problem since the time you sent me that last message Only a little problem appeared in the IDE I don't know where the error comes from
1Lucas1.apk
1Lucas1.apk•2y ago
No description
1Lucas1.apk
1Lucas1.apk•2y ago
I've already deleted all the code and the error still hasn't disappeared, I just know that the bot is gone @Ghos't Could you show the pause code part? In the meantime I will try to fix this environment error
afraid-scarlet
afraid-scarletOP•2y ago
No description
1Lucas1.apk
1Lucas1.apk•2y ago
What defines queue?
afraid-scarlet
afraid-scarletOP•2y ago
No description
1Lucas1.apk
1Lucas1.apk•2y ago
?play all i want
Blobit - Moonlink.js
discordlogo Music.
<:Nota_Musica__Mlink:960665601574055966>╺╸Title:
<:Estrela_Mlink:960660485999587348>╺╸Uri:
<:emoji_21:967836966714503168>╺╸Author:
DisneyMusicVEVO
<:emoji_23:967837516558393365>╺╸Duration:
0 Days, 0 Hours, 3 Minutes, 185 Seconds
Request for: 1lucas1.apk
Blobit - Moonlink.js
Olivia Rodrigo - All I Want (Official Video) is playing now
1Lucas1.apk
1Lucas1.apk•2y ago
?eval client.moon.players.get(message.guild.id).pause()
Blobit - Moonlink.js
Promise { true }
Promise { true }
1Lucas1.apk
1Lucas1.apk•2y ago
?play dumb dumb ?play dumb dumb
Blobit - Moonlink.js
discordlogo Music.
<:Nota_Musica__Mlink:960665601574055966>╺╸Title:
<:Estrela_Mlink:960660485999587348>╺╸Uri:
<:emoji_21:967836966714503168>╺╸Author:
mazie
<:emoji_23:967837516558393365>╺╸Duration:
0 Days, 0 Hours, 2 Minutes, 132 Seconds
Request for: 1lucas1.apk
1Lucas1.apk
1Lucas1.apk•2y ago
?eval client.moon.players.get(message.guild.id).pause()
Blobit - Moonlink.js
Promise { <pending> }
Promise { <pending> }
1Lucas1.apk
1Lucas1.apk•2y ago
?eval client.moon.players.get(message.guild.id).pause()
Blobit - Moonlink.js
Promise { true }
Promise { true }
1Lucas1.apk
1Lucas1.apk•2y ago
?eval client.moon.players.get(message.guild.id).resume()
Blobit - Moonlink.js
Promise { <pending> }
Promise { <pending> }
1Lucas1.apk
1Lucas1.apk•2y ago
Okay, the error is the most beast there is! num if @Ghos't I published the version correcting this bug
afraid-scarlet
afraid-scarletOP•2y ago
thx man I appreciate that
1Lucas1.apk
1Lucas1.apk•2y ago
You are welcome
afraid-scarlet
afraid-scarletOP•2y ago
I still face a problem when I use the pause command, the first bot responds, but the second bot does not respond to the command
MEE6
MEE6•2y ago
GG @Ghos't, you just advanced to level 3!
afraid-scarlet
afraid-scarletOP•2y ago
first bot queue.data
No description
afraid-scarlet
afraid-scarletOP•2y ago
second bot queue.data
No description
afraid-scarlet
afraid-scarletOP•2y ago
@1Lucas1.apk
1Lucas1.apk
1Lucas1.apk•2y ago
Mercy, I already left a console.log in the codes lol
afraid-scarlet
afraid-scarletOP•2y ago
- @1Lucas1.apk sorry for mention
1Lucas1.apk
1Lucas1.apk•2y ago
Man, then I would need to see half of the code to find where the problem could be 😦 Send me the server he is on in private 🙂
afraid-scarlet
afraid-scarletOP•2y ago
@1Lucas1.apk dose the new update fix the problem

Did you find this page helpful?