i'm trying to make a discord bot. I'm using AkairoClient as a framework, within it there's an option to set a prefix. what I have is the following code:
// HANDLERS
this.commandHandler = new CommandHandler(this, {
prefix: msg => {
let prefix;
console.log('first')
con.query(`SELECT * FROM info WHERE id = ${msg.guild.id}`, (err, rows) => {
if (!err) prefix = rows[0].prefix;
console.log('Second')
});
console.log('third')
return prefix ?? '!';
},
blockBots: true,
/* Rest of code here ...*/
});
When i execute this, The console prints:
- First
- Third
- First
- Third
- Second
- Second
I'm having issues understanding on how should I make this work properly as I want the prefix
to get the value of rows, but in this instance prefix
is returning as undefined
before the query finishes