From aa7251594bcf00f350956ef92445293f52834c56 Mon Sep 17 00:00:00 2001
From: Cristiano Pires
Date: Mon, 4 Dec 2023 23:51:37 +0000
Subject: [PATCH] Server side implementation of Allow invites
---
controller/api.js | 3 +--
public/js/dashboard.js | 12 +++++++++---
views/dashboard.ejs | 2 +-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/controller/api.js b/controller/api.js
index 3ac89fd..a007d08 100644
--- a/controller/api.js
+++ b/controller/api.js
@@ -56,6 +56,7 @@ exports.guildData = (io,bot)=>
id:guild.id,
music:aux.guild?aux.guild.guild[0].music:false,
strikes:aux.guild?aux.guild.guild[0].strikes:false,
+ allowInvites:aux?.guild?.guild[0]?.allowInvites,
name:guild.name,
icon:guild.icon?`https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}.webp`:'https://cdn3.iconfinder.com/data/icons/popular-services-brands-vol-2/512/discord-512.png',
features:guild.features,
@@ -136,13 +137,11 @@ exports.updateGuild = (io)=>
{
return (req, res)=>
{
-
GuildM.findOne({gID:req.body.guildID})
.then(
(guild, err)=>
{
if(err || guild.length) return res.json({Error:'No guild'});
-
guild[`${req.body.property}`] =! guild[`${req.body.property}`];
GuildM.updateOne({gID:req.body.guildID}, guild).then(()=>
{
diff --git a/public/js/dashboard.js b/public/js/dashboard.js
index e2dfcad..fe3ca3b 100644
--- a/public/js/dashboard.js
+++ b/public/js/dashboard.js
@@ -61,12 +61,16 @@ function handleSettigns(event)
popup.classList.remove('hidden');
popup.children[1].textContent = guild.name;
popup.children[1].id = guild.id;
- let music = document.getElementById('music')
+ let music = document.getElementById('music');
music.textContent = guild.music? 'check_box' :'check_box_outline_blank';
- let strikes = document.getElementById('strikes')
+ let strikes = document.getElementById('strikes');
strikes.textContent = guild.strikes? 'check_box' :'check_box_outline_blank';
+ let allowInvites = document.getElementById('allowInvites');
+ allowInvites.textContent = guild.allowInvites? 'check_box' : 'check_box_outline_blank';
music.onclick = requestChange;
strikes.onclick = requestChange;
+ allowInvites.onclick = requestChange;
+
}
function handleClose(element)
@@ -82,7 +86,7 @@ function handleClose(element)
}
async function requestChange()
{
-
+ console.log('here')
return await fetch(`${window.location.origin}/api/change`,
{
method: "POST",
@@ -101,6 +105,8 @@ async function requestChange()
music.textContent = res.music? 'check_box' :'check_box_outline_blank';
let strikes = document.getElementById('strikes')
strikes.textContent = res.strikes? 'check_box' :'check_box_outline_blank';
+ let allowInvites = document.getElementById('allowInvites');
+ allowInvites.textContent = res.allowInvites? 'check_box' : 'check_box_outline_blank';
}
})
.catch(console.error);
diff --git a/views/dashboard.ejs b/views/dashboard.ejs
index 9f28c09..a319987 100644
--- a/views/dashboard.ejs
+++ b/views/dashboard.ejs
@@ -44,7 +44,7 @@
info
Allow invites to other servers on your server.
- check_box_outline_blank
+ check_box_outline_blank
Role rules
Feeds