I wrote a code, my goal is to easily retrieve information from the sqlite3 database without always having to do "db.get ..." so I make a function but it doesn't work , can you help me ?
Here is the code:
exports.getGuildLanguage = function(guild) {
var lang = null;
db.get("SELECT guildLanguage FROM a" + guild.id, (err, data) =>{
if(err){
throw err;
}
lang = data;
(data.guildLanguage);
})
return lang;
};
in "getters.js" file And in another class
const getters = require("../getters.js") // récupération du fichier
console.log(getters.getGuildLanguage(message.guild)) // envoie du message
Please help me ! Thanks for your reponse in advance
PS : Sorry, my english is bad because I am french