discord_bot/util/custom_commands/getOwnerOfCustomCommand.js
SileNce5k 0c45055e0f
All checks were successful
CI / CI (push) Successful in 21s
Lint Codebase / eslint (push) Successful in 16s
Use SQL on owner custom command subcommand
2024-12-19 20:19:38 +01:00

24 lines
No EOL
602 B
JavaScript

const sqlite3 = require('sqlite3').verbose();
module.exports = async function(customName){
const db = new sqlite3.Database("data/database.db");
let author = await new Promise((resolve, reject)=>{
db.get("SELECT * FROM customCommands WHERE customName = ? AND isDeleted = 0", [customName],
function(error, command){
if(error){
console.error(error)
let author = "Error when getting the owner of this custom command. Check console.";
reject(author)
}else {
let author;
if(command){
author = command.author;
}
resolve(author)
}
})
})
return author;
}