Code:
client.on('interactionCreate', async (interaction) => {
if (interaction.isCommand()) {
const { commandName, options } = interaction
if (commandName === 'istatistik') {
await interaction.deferReply({ephemeral: true})
//await interaction.editReply(`Geçiçi olarak devre dışı!`)
let readyFunction = await isReady(commandName);
await console.log("Ready function output:") //I know i can merge console.log's to one but if its an array or promise it wont display the input so that's the way for now.
await console.log(readyFunction)
}
}
})
async function isReady(cmdName) {
let ready = null
let embed = new Discord.MessageEmbed()
let returnArray = []
embed.setColor("RED")
embed.setTimestamp()
embed.setFooter({
text: client.user.username,
iconURL: client.user.avatarURL()
})
embed.addField(`:x: Bot hazır değil!`, `Lütfen 10 dakika bekleyip yeniden deneyin!`)
let sqlSorgusu2 = `SELECT * FROM \`hanibor\`.\`botready\`;`
await connection.query(sqlSorgusu2, async function (err, results) {
if (err) throw err.message;
if(!results[0]){
console.log(`${cmdName} is being used but bot is not ready.`)
ready = false
await returnArray.push(ready, embed)
await console.log("Return array:")
await console.log(returnArray)
return returnArray
} else if (results[0]) {
if (results[0].status.toLowerCase()=="ok") {
ready = true
await returnArray.push(ready)
await console.log("Return array:")
await console.log(returnArray)
return returnArray
}
}
});
}```
Console output:
```Ready function output:
undefined
istatistik is being used but bot is not ready.
Return array:
[
false,
MessageEmbed {
type: 'rich',
title: null,
description: null,
url: null,
color: 15548997,
timestamp: 1670611520982,
fields: [ [Object] ],
thumbnail: null,
image: null,
video: null,
author: null,
provider: null,
footer: {
text: 'Removed',
iconURL: 'Removed'
}
}
]```