From fc415a27ac30a50f8cf2bb9d651008bbb192f844 Mon Sep 17 00:00:00 2001 From: masterhc Date: Sun, 11 Feb 2024 01:11:18 +0000 Subject: [PATCH] Implementation of HTMX server side --- controller/api.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/controller/api.js b/controller/api.js index a007d08..1d8235c 100644 --- a/controller/api.js +++ b/controller/api.js @@ -1,4 +1,5 @@ const GuildM = require('../models/guilds'); +const STRIKES = require('../models/strikes'); const roleRulesM = require('../models/autoRoleRule'); const feedsM = require('../models/feeds'); const xmlparser = require('xml-js') @@ -446,3 +447,51 @@ exports.deleteFeed = (req,res) => { feedsM.findOneAndDelete({_id:req.headers.feedid}).then(()=>{res.json({success:true})}).catch(error=>{res.json({error})}) } + + + +/** + * + *! '/strikes/:id/:userid/:strikeid?' + */ + +exports.strikeDashboard = (bot)=> +{ + return async (req, res)=> + { + // const user = bot.users.cache.get(req.params.userid) + const guild = bot.guilds.cache.get(req.params.id); + const strikes = await STRIKES.find({guildID:req.params.id}) + const moderator = req.params.userid; + res.render('strikesDashboard.ejs', {strikes, guild, moderator}) + } +} +exports.getStrikes = (bot)=> +{ + return async (req,res)=> + { + var strikes = await STRIKES.find({guildID:req.params.id}); + const moderator = req.params.userid + res.render('strikelist.ejs', {strikes}) + } +} +exports.updateStrikes = (bot)=> +{ + return async (req,res)=> + { + const strike = await STRIKES.findByIdAndUpdate(req.params.strikeid, {validated:true}); + const strikes = await STRIKES.find({guildID:req.params.id}) + const moderator = req.params.userid; + res.render('strikelist.ejs', {strikes, moderator}) + } +} +exports.deleteStrikes = (bot)=> +{ + return async (req,res)=> + { + await STRIKES.findByIdAndDelete(req.params.strikeid); + const strikes = await STRIKES.find({guildID:req.params.id}) + const moderator = req.params.userid; + res.render('strikelist.ejs', {strikes, moderator}) + } +} \ No newline at end of file