Refactored Database Connection, Fixed JSDocs, initial steps for MessageReaction Handling

This commit is contained in:
steev
2022-11-30 14:10:18 +01:00
parent be837afcf0
commit 599b5a0ab1
3 changed files with 41 additions and 10 deletions

View File

@ -1,7 +1,7 @@
const sql = require('mysql');
var Database = async (db) => {
var server = sql.createConnection({
const Database = async (db) => {
const server = sql.createConnection({
host : db.HOST,
user : db.USER,
password : db.PASSWORD,

View File

@ -1,4 +1,33 @@
const HandleReaction = async (reaction, Database) => {
const {MessageReaction, PartialMessageReaction, User} = require("discord.js")
const {Connection} = require("mysql")
/**
* handles reactions in both ways
* @param {MessageReaction | PartialMessageReaction} reaction the message reaction
* @param {User} user
* @param {Connection} Database current databes instance
* @param {string} Action string of current action happening
*/
const HandleReaction = async (reaction, user, database, Action) => {
// Handle if reaction is partial and therefor might throw api errors
if (reaction.partial()){
try{
// global values
let react = await reaction.fetch()
// Route Actions
switch (Action) {
case "add":
react.
break;
case "remove":
break;
}
}catch (e) {
console.log(e)
return
}
}
}
module.exports = {HandleReaction}