Add whitelist and chat (LLM) feature
Some checks failed
CI / CI (push) Has been cancelled

This commit is contained in:
SileNce5k 2025-04-30 11:35:32 +02:00
parent 1fd5f6cc6a
commit bb562be042
Signed by: SileNce
GPG key ID: B0A142BB4291B204
4 changed files with 137 additions and 0 deletions

View file

@ -0,0 +1,41 @@
const sqlite3 = require('sqlite3').verbose();
module.exports = {
name: 'whitelist',
description: 'Whitelist different commands that need whitelisting.',
admin: true,
async execute({message, args, prefix}) {
if(args < 2){
message.channel.send(`You need to supply the command and channel that you want to whitelist\n\`${prefix}whitelist <command> <server_id>\``);
}
let command = args[0];
let guild = args[1];
// TODO: First check if the bot has access to that guild before whitelisting.
const databasePath = 'data/database.db'
const db = new sqlite3.Database(databasePath)
let err = false;
await new Promise((resolve, reject)=>{
db.run(`INSERT INTO whitelist (
serverId,
command,
date
) VALUES (?, ?, ?)`,
[
guild,
command,
new Date().getTime()
], function (error) {
if (error) {
console.error(error);
err = true;
resolve();
}else{
resolve();
}
});
})
if(!err)
message.channel.send("Command has been whitelisted in this server.")
else message.channel.send("Could not whitelist the server with that command. Check the logs.")
}
};