rolerules on the site

master
Cristiano Pires 2 years ago
parent e20c1a234d
commit a449b65c73

@ -1,36 +1,94 @@
const GuildM = require('../models/guilds');
const roleRulesM = require('../models/autoRoleRule')
exports.hasRem = (io)=>
exports.getUser = (io)=>
{
return(req,res)=>
{
GuildM.find({gID:req.body.guildID})
.then(
(guild,err)=>
{
if(err || guild.length==0) return res.json({hasRem:false})
return res.json({hasRem:true})
}
)
fetch('https://discord.com/api/users/@me',
{
headers: {
authorization: req.headers.authorization,
},
})
.then(result=>result.json())
.then(response =>
{
res.json(response);
})
}
};
exports.guildData = (io)=>
exports.guildData = (io,bot)=>
{
return (req, res)=>
return async (req, res)=>
{
GuildM.find({gID:req.body.guildID})
.then(
(guild,err)=>
let userGuilds = await fetch('https://discord.com/api/users/@me/guilds',
{
headers: {
authorization: req.headers.authorization,
},
})
.then(result => result.json())
.then(response =>
{
if(response.message) return response.message
return response.filter(x=>x.owner==true);
})
var promises = [];
if(typeof userGuilds == 'string') return res.json({Error:userGuilds})
for(var guild of userGuilds) {
promises.push(new Promise((resolve, reject) => {
(async (guild)=>
{
var aux = await getSpecificGuildData(guild.id);
var roleRules = aux ? await getRoleRules(guild.id):null;
const dataObject =
{
id:guild.id,
music:aux.guild?aux.guild.guild[0].music:false,
strikes:aux.guild?aux.guild.guild[0].strikes:false,
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,
hasRem:aux.extra?true:false,
memberCount:aux.extra?aux.extra.memberCount:null,
roleRules
};
resolve(dataObject);
})(guild)
}));
}
Promise.all(promises).then((values) => {
return res.json(values);
});
}
async function getSpecificGuildData(guildID)
{
var extra = bot.guilds.cache.get(guildID)
var guild = await GuildM.find({gID:guildID})
.then((guild,err)=>
{
if(err || guild.length==0) return res.json(null)
return res.json(guild[0])
}
)
if(err || guild.length==0) return;
return {guild};
})
return {guild, extra};
}
async function getRoleRules(guildid)
{
return await roleRulesM.find({gID:guildid}).then((err, rules)=>
{
if(err || rules.length==0) return
return rules
})
}
}
exports.updateGuild = (io)=>
{
return (req, res)=>
@ -49,4 +107,119 @@ exports.updateGuild = (io)=>
})
})
}
}
}
exports.getMessage = (bot)=>
{
return async (req, res)=>
{
const TextChannels = bot.guilds.cache.get(req.headers.guildid).channels.cache.filter(x=>x.type==0);
TextChannels.forEach(channel => {
(async (channel)=>
{
var message
try {
message = await channel.messages.fetch(req.headers.messageid);
} catch (error) {
//message doesn't exist on this channel or at all
}
if(message)
{
message = message.content
if(message.split('***').length %2 == 1) message = message.replaceAll('***', '');
if(message.split('**').length %2 == 1) message = message.replaceAll('**', '');
if(message.split('*').length %2 == 1) message = message.replaceAll('*', '');
if(message.split('~~').length %2 == 1) message = message.replaceAll('~~', '');
if(message.split('```').length %2 == 1) message = message.replaceAll('```', '');
if(message.split('``').length %2 == 1) message = message.replaceAll('``', '');
if(message.split('`').length %2 == 1) message = message.replaceAll('`', '');
res.json({message})
}
})(channel)
});
}
}
exports.getRules = async (req,res)=>
{
var payload;
if(req.headers.guildid)
{
payload = await roleRulesM.find({gID:req.headers.guildid})
.then(rules =>{return rules})
.catch(()=>{return null})
return res.json(payload);
}
payload = await roleRulesM.findOne({_id:req.headers.id})
.then(rule=>{return rule})
.catch(()=>{return null})
return res.json(payload);
}
exports.updateRule = (bot)=>
{
return async (req, res)=>
{
let args = req.headers;
if(args.isnew == 'true')
{
const validationResult = await confirmArgs(args);
if (validationResult.error) return res.json({error:validationResult.error})
var rule = new roleRulesM();
rule.gID = validationResult.gID;
rule.mID = validationResult.mID;
rule.roleID = validationResult.roleID;
rule.roleEmoji = validationResult.roleEmoji;
rule.roleName = validationResult.roleName;
rule.save(err=>
{
if(err)res.json(err);
res.json({success:true,rule})
})
}
else
{
const validationResult = await confirmArgs(args);
if (validationResult.error) return res.json({error:validationResult.error})
roleRulesM.findOne({id:args.id}).then(rule=>
{
if(!rule) return res.json({error:'DB Error'});
rule.gID = validationResult.gID;
rule.mID = validationResult.mID;
rule.roleID = validationResult.roleID;
rule.roleEmoji = validationResult.roleEmoji;
rule.roleName = validationResult.roleName;
roleRulesM.updateOne({_id:rule.id}, rule,{upsert:true}).then(updatedG=>
{
res.json({success:true, rule})
})
})
}
}
async function confirmArgs(args)
{
var mID = args.messageid;
var roleID = args.roleid;
var roleEmoji = args.emojiid;
var gID = args.gid;
var roleName;
if(!(mID && roleID && roleEmoji && gID)) return mID?(roleID?(roleEmoji? false: {error:'Emoji ID'}):{error:'Role ID'}):{error:'Message ID'};
var m = await (async ()=>
{
for(const [id, channel] of bot.channels.cache)
{
if(channel.type == 0)
{
try {
const exists = await bot.channels.cache.get(id).messages.fetch(mID);
if(exists) return m = true;
} catch (error) {}
}
}
})();
const r = bot.guilds.cache.get(gID).roles.cache.get(roleID);
const e = bot.guilds.cache.get(gID).emojis.cache.get(roleEmoji);
if(!m || !r || !e) return m?(r?(e?false:{error:'Emoji ID'}):{error:'Role ID'}):{error:'Message ID'}
roleName = r.name;
return {mID, roleID, roleEmoji, roleName, gID}
}
}

@ -6,9 +6,9 @@ body
width: 100%;
align-items: center;
justify-content: center;
overflow: hidden;
background-color: #071c24;
}
#userWrapper
{
position: absolute;
@ -17,6 +17,9 @@ body
transform: translateX(-50%);
height: 15vh;
width: 80%;
background-color: var(--card-color);
border-radius: 10px;
border: 1px solid #fffff042;
}
#avatar
{
@ -27,6 +30,7 @@ body
position: relative;
top:2vh;
left: 10%;
border-radius: 10px;
}
#userName
{
@ -79,13 +83,11 @@ body
.popup
{
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%, -50%);
height: 30%;
width: 50%;
top:calc(50% - 15%);
background-color: rgba(210, 252, 253, 0.541);
border-radius: 1%;
border-radius: 5px;
border: 2px solid #020608;
z-index: 10;
text-align: center;
@ -96,9 +98,10 @@ h1
position: relative;
top: -50%;
}
h3
.guildname
{
font-family: 'Lato';
margin-top: 0.6em;
font-family: 'Lato'
}
p
{
@ -106,10 +109,7 @@ p
padding-top: 1vh;
padding-bottom: 1vh;
}
p:nth-child(even)
{
background-color: #071c2498;
}
.hidden
{
display: none;
@ -119,4 +119,352 @@ p:nth-child(even)
position: relative;
top:1vh;
right:1vh;
}
#Guilds
{
/* background-color: ivory; */
width: 80%;
height: 60%;
position: absolute;
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
}
.true
{
background-color: rgba(0, 52, 94, 0.123) !important;
border-radius: 5px;
}
img
{
width: 50%;
height: 100%;
}
/* width */
::-webkit-scrollbar {
width: 10px;
}
/* Track */
::-webkit-scrollbar-track {
background: #020a0e91;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #076969;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #064e4e;
}
.imgtrue
{
filter:grayscale(0.2) !important;
}
.imgfalse
{
filter:grayscale(0.7) !important;
}
:root {
--card-color: rgb(23, 23, 23);
}
body {
margin: 0px;
overflow-y: scroll;
overflow-x: hidden;
padding: 0px;
}
#cards {
display: flex;
flex-wrap: wrap;
gap: 8px;
width: calc(100% - 20px);
justify-content: center;
}
#cards:hover > .card::after {
opacity: 1;
}
.card {
background-color: rgba(255, 255, 255, 0.1);
border-radius: 10px;
cursor: pointer;
display: flex;
height: 260px;
flex-direction: column;
position: relative;
width: 300px;
}
.card:hover::before {
opacity: 1;
}
.card::before,
.card::after {
border-radius: inherit;
content: "";
height: 100%;
left: 0px;
opacity: 0;
position: absolute;
top: 0px;
transition: opacity 500ms;
width: 100%;
}
.card::before {
background: radial-gradient(
800px circle at var(--mouse-x) var(--mouse-y),
rgba(255, 255, 255, 0.06),
transparent 40%
);
z-index: 3;
}
.card::after {
background: radial-gradient(
600px circle at var(--mouse-x) var(--mouse-y),
rgb(255, 255, 255),
transparent 40%
);
z-index: 1;
}
.card > .card-content {
background-color: var(--card-color);
border-radius: inherit;
display: flex;
flex-direction: column;
flex-grow: 1;
inset: 1px;
padding: 10px;
position: absolute;
z-index: 2;
}
/* -- ↓ ↓ ↓ extra card content styles ↓ ↓ ↓ -- */
h1, h2, h3, h4, span {
color: rgb(240, 240, 240);
font-family: "Rubik", sans-serif;
font-weight: 400;
margin: 0px;
}
i {
color: rgb(240, 240, 240);
}
.card-image {
align-items: center;
display: flex;
margin-top:2vh;
height: 140px;
justify-content: center;
overflow: hidden;
}
.card-image > i {
font-size: 6em;
opacity: 0.25;
}
.card-info-wrapper {
align-items: center;
display: flex;
flex-grow: 1;
justify-content: flex-start;
padding: 0px 20px;
}
.card-info {
align-items: flex-start;
display: flex;
gap: 10px;
}
.card-info > i {
font-size: 1em;
height: 20px;
line-height: 20px;
}
.card-info-title > h3 {
font-size: 1.1em;
line-height: 20px;
}
.card-info-title > h4 {
color: rgba(255, 255, 255, 0.5);
font-size: 0.85em;
margin-top: 8px;
}
#RoleRules
{
cursor:pointer;
}
.rules
{
border: 2px solid #020608;
height: 20vh;
position: absolute;
top:1%;
overflow-y: scroll;
width: 60%;
left: 20%;
background-color:#071c24de;
color: ivory;
border-radius: 5px;
}
.roleRuleWrapper
{
height: 20em;
border: 1px solid ivory;
aspect-ratio: 16/9;
position:absolute;
top:-50%;
left:0;
font-size:1em;
top:50%;
left:50%;
transform: translateX(-50%) translateY(-50%);
text-align:center;
border-radius: 10px;
overflow: hidden;
}
.roleRuleWrapper:before
{
content:'';
height: 20em;
aspect-ratio: 16/9;
position:absolute;
top:0;
left:0;
background-color:#5a8786;
z-index:-1;
}
.roleRuleWrapper:after
{
content:attr(data-before);
height: 9em;
font-family: 'Lato';
aspect-ratio: 16/9;
position:absolute;
top:48%;
left:50%;
transform:translateX(-50%) translateY(-50%);
z-index:-1;
filter: blur(1px);
background-image: linear-gradient(ivory, #2a2a291f);
background-size: 100%;
-webkit-background-clip: text;
-moz-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-text-fill-color: transparent;
}
.roleRule
{
color: ivory;
font-family: 'Lato';
font-weight: bolder;
margin-top: 1em;
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
}
.role
{
color:ivory;
position:absolute;
left: 10%;
top:58%;
}
.emoji
{
color:ivory;
position:absolute;
right: 10%;
top:58%;
}
.roleID
{
transform:translateY(250%);
background-color:#00000054;
border:2px solid transparent;
width: 37.5%;
}
p
{
font-weight:bold;
font-family: 'Lato';
}
input
{
font-weight:bold;
}
.emojiID
{
transform:translateY(250%);
background-color:#00000054;
border:2px solid transparent;
color:ivory;
text-align:right;
width: 37.5%;
}
.message
{
color:ivory;
position:absolute;
left: 30%;
top:40%;
}
.messageID
{
transform:translateY(250%);
background-color:#00000054;
border:2px solid transparent;
width: 37.5%;
}
.bt
{
width:20%;
height:1.5em;
background-color: #00345e69;
border-radius: 25px;
border: 2px solid #00345eb5;
position:absolute;
bottom:5%;
left:50%;
transform:translateX(-50%);
color:ivory;
cursor:pointer;
}
#emojiImg
{
width:1.5em;
height:1.5em;
margin-right:1em;
border:0px solid trasparent;
}
#close_bt2
{
color:ivory;
float:right;
margin-right:0.5em;
margin-top:0.5em;
cursor:pointer;
}

@ -1,16 +1,22 @@
var userID;
var guildsCache = new Map();
window.onload = async () =>
{
const fragment = new URLSearchParams(window.location.hash.slice(1));
const [accessToken, tokenType] = [fragment.get('access_token'), fragment.get('token_type')];
var guilds;
if (!accessToken) return window.location.href = '/';
updateUser(accessToken, tokenType);
updateGuildData(accessToken, tokenType);
document.getElementById('RoleRules').onclick = handleToggleRules;
};
function updateUser(accessToken, tokenType)
{
const avatar = document.getElementById('avatar');
const userName = document.getElementById('userName');
var table = document.getElementById('guilds')
if (!accessToken) return window.location.href = '/';
fetch('https://discord.com/api/users/@me',
fetch(`${window.location.origin}/api/getUser`,
{
method: "POST",
headers: {
authorization: `${tokenType} ${accessToken}`,
},
@ -20,129 +26,252 @@ window.onload = async () =>
{
userID = response.id;
avatar.style.backgroundImage = `url(https://cdn.discordapp.com/avatars/${response.id}/${response.avatar}.jpeg)`
userName.textContent = response.username
userName.textContent = response.username+"'s servers:"
})
.catch(console.error);
fetch('https://discord.com/api/users/@me/guilds',
}
function updateGuildData(accessToken, tokenType)
{
fetch(`${window.location.origin}/api/getGuildData`,
{
method: "POST",
headers: {
authorization: `${tokenType} ${accessToken}`,
},
})
.then(result => result.json())
.then(response =>
.then(guilds =>
{
guilds = response.filter(x=>x.owner==true);
for(var guild of guilds)
{
(async (guild)=>
{
var row = document.createElement('tr');
var name = document.createElement('td');
name.textContent = guild.name;
var settings = document.createElement('td');
settings.id = guild.id;
var gear = document.createElement('span');
gear.classList.add('material-symbols-outlined')
gear.onclick = handleSettigns
gear.textContent = 'settings';
row.appendChild(name);
var addRemData = document.createElement('td');
if(!await hasRem(guild.id))
{
var button = document.createElement('div');
button.classList.add('DiscordAddBtn');
addRemData.appendChild(button);
}
row.appendChild(addRemData);
settings.appendChild(gear);
row.appendChild(settings);
table.appendChild(row)
})(guild)
}
if(guilds.Error) return console.log(guilds.Error)
guildsCache = new Map();
guilds.forEach(guild => {
guildsCache.set(guild.id, guild)
});;
makeCards(guilds);
})
.catch(console.error);
};
}
function handleSettigns(event)
{
var guildID = event.target.parentNode.id;
var guildName = event.target.parentNode.parentNode.childNodes[0].textContent;
var popup = document.getElementById('popup');
const data = {guildID}
fetch(`${window.location.origin}/api/getGuildData`,
var guild = guildsCache.get(event.target.id);
if(!guild.hasRem) return window.open('https://discord.com/api/oauth2/authorize?client_id=356104008366030863&permissions=8&scope=bot')
popup.classList.remove('hidden');
popup.children[1].textContent = guild.name;
popup.children[1].id = guild.id;
let music = document.getElementById('music')
music.textContent = guild.music? 'check_box' :'check_box_outline_blank';
let strikes = document.getElementById('strikes')
strikes.textContent = guild.strikes? 'check_box' :'check_box_outline_blank';
music.onclick = requestChange;
strikes.onclick = requestChange;
}
function handleClose(element)
{
if(element.parentNode.id == 'roleRuleWrapper') document.getElementById('popup').classList.remove('hidden');
element.parentNode.classList.add('hidden');
}
async function requestChange()
{
return await fetch(`${window.location.origin}/api/change`,
{
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data), // body data type must match "Content-Type" header
body: JSON.stringify({guildID:event.target.parentNode.parentNode.children[1].id,userID, property:event.target.id}), // body data type must match "Content-Type" header
})
.then(result => result.json())
.then(res =>
{
popup.classList.remove('hidden');
popup.children[1].textContent = guildName;
popup.children[1].id = guildID;
let music = document.getElementById('music')
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';
music.onclick = requestChange;
strikes.onclick = requestChange;
if(!res.error)
{
let music = document.getElementById('music')
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';
}
})
.catch(console.error);
}
async function hasRem(guildID)
async function makeCards(data)
{
return await fetch(`${window.location.origin}/api/hasRem`,
const canvas = document.createElement('div')
canvas.classList.add('cards');
canvas.id = 'cards'
for(var item of data)
{
method: "POST",
(async ()=>
{
var card = await makeCard(item);
canvas.appendChild(card);
})(item)
}
document.getElementById('Guilds').appendChild(canvas)
document.getElementById("cards").onmousemove = e => {
for(const card of document.getElementsByClassName("card")) {
const rect = card.getBoundingClientRect(),
x = e.clientX - rect.left,
y = e.clientY - rect.top;
card.style.setProperty("--mouse-x", `${x}px`);
card.style.setProperty("--mouse-y", `${y}px`);
};
}
document.getElementById('cards').onclick = handleSettigns;
}
async function makeCard(guild)
{
const card = document.createElement('div')
card.innerHTML = ` <div id='${guild.id}'class="card">
<div class="card-content ">
<div class="card-image img${guild.hasRem}">
<img src=${guild.icon}></img>
</div>
<div class="card-info-wrapper ${guild.hasRem}">
<div class="card-info">
<div class="card-info-title">
<h3>${guild.name}</h3>
<h4>${guild.memberCount?guild.memberCount + ' users on the server.':'Rem is not on this server yet.'} </h4>
</div>
</div>
</div>
</div>
</div>`
return card
}
async function getRules(guildID)
{
return await fetch(`${window.location.origin}/api/getRules`,
{
method: "GET",
mode: "cors",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({guildID}), // body data type must match "Content-Type" header
headers: {guildID},
})
.then(result => result.json())
.then(res =>
{
return res.hasRem;
return res
})
.catch(console.error);
}
async function handleToggleRules(element)
{
var guildID = element.target.parentNode.getElementsByTagName('h3')[0].id;
var rulesElement=document.getElementById('rules');
var rules = await getRules(guildID);
if(!rules) return
var ruleArr = []
for(var rule of rules)
{
ruleArr.push(`<p id="${rule._id}" onclick="changeRule(this)" class="addRoleName">${rule.roleName}</p>`)
}
rulesElement.innerHTML = `
<i onclick="handleClose(this)" class="close material-symbols-outlined" id="close_bt">
cancel
</i>
<p id="newRole" onclick="addRule(this)">New Role</p>
${ruleArr.join('')}
`
rulesElement.classList.remove('hidden')
}
function handleClose(element)
function addRule(element)
{
element.parentNode.classList.add('hidden');
element.parentNode.parentNode.classList.add('hidden');
var ruleWrapper = document.getElementById('roleRuleWrapper');
ruleWrapper.classList.remove('hidden');
document.getElementsByClassName('roleRuleWrapper')[0].setAttribute('data-before','Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas in elit vel nisi sagittis egestas. Donec a laoreet justo. Morbi interdum orci quis tempor tempor. Aenean tempus urna eget placerat maximus. Maecenas vitae condimentum felis, et mollis velit. Duis diam arcu, volutpat ut lectus et, aliquam vestibulum ante. Mauris dignissim libero quis condimentum interdum. Morbi dictum ex faucibus mi vehicula, sed blandit ex molestie. Pellentesque lacinia blandit pellentesque. Nullam at nisl dui.')
document.getElementById('roleRule').innerText = 'New Rule'
document.getElementById('roleID').placeholder = 'Role ID'
document.getElementById('emojiID').placeholder = 'Emoji ID'
document.getElementById('messageID').placeholder = 'Message ID'
document.getElementById('emojiImg').src = 'images/favicon.ico';
}
async function requestChange()
function updateRule(element)
{
return await fetch(`${window.location.origin}/api/change`,
var isNew=false;
if(element.parentNode.children[1].innerText == 'New Rule') isNew = true;
var ruleID;
if(!isNew) ruleID = document.getElementById('roleRule').classList[1];
var messageid = document.getElementById('messageID').value;
var roleid =document.getElementById('roleID').value;
var emojiid =document.getElementById('emojiID').value;
var gid = document.getElementsByClassName('guildname')[0].id;
fetch(`${window.location.origin}/api/updateRule`,
{
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({guildID:event.target.parentNode.parentNode.children[1].id,userID, property:event.target.id}), // body data type must match "Content-Type" header
})
headers: {messageid, roleid, emojiid, gid,isNew, ruleID},
})
.then(result => result.json())
.then(res =>
{
if(!res.error)
console.log(res);
if(res.success)
{
let music = document.getElementById('music')
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';
element.parentNode.classList.add('hidden')
document.getElementById('popup').classList.remove('hidden');
}
else alert(res.error);
})
.catch(console.error);
}
async function getRule(id)
{
return await fetch(`${window.location.origin}/api/getRules`,
{
method: "GET",
mode: "cors",
headers: {id},
})
.then(result => result.json())
.then(res =>
{
return res
})
.catch(console.error);
}
async function getMessage(guildid, messageid)
{
return await fetch(`${window.location.origin}/api/getMessage`,
{
method: "GET",
mode: "cors",
headers: {guildid, messageid},
})
.then(result => result.json())
.then(res =>
{
return res
})
.catch(console.error);
}
async function changeRule(element)
{
var rule = await getRule(element.id)
var message = await getMessage(rule.gID,rule.mID);
message = message.message;
element.parentNode.classList.add('hidden');
element.parentNode.parentNode.classList.add('hidden')
var ruleWrapper = document.getElementById('roleRuleWrapper');
ruleWrapper.classList.remove('hidden');
document.getElementsByClassName('roleRuleWrapper')[0].setAttribute('data-before', message)
document.getElementById('roleRule').innerText = rule.roleName;
document.getElementById('roleRule').classList.add(rule._id);
document.getElementById('roleID').placeholder = rule.roleID;
document.getElementById('emojiID').placeholder = rule.roleEmoji;
document.getElementById('messageID').placeholder = rule.mID;
document.getElementById('emojiImg').src = `https://cdn.discordapp.com/emojis/${rule.roleEmoji}.webp`;
}

@ -2,13 +2,17 @@ const router = require('express').Router();
const homeController = require('../controller/home.js');
const dash = require('../controller/dashboard.js');
const api = require('../controller/api.js');
module.exports = (io)=>
module.exports = (io, bot)=>
{
router.route('/').get(homeController.home(io));
router.route('/api/hasRem').post(api.hasRem(io));
router.route('/api/getGuildData/').post(api.guildData(io));
router.route('/api/getUser').post(api.getUser(io));
router.route('/api/getGuildData/').post(api.guildData(io, bot));
router.route('/api/Change/').post(api.updateGuild(io));
router.route('/api/getRules').get(api.getRules);
router.route('/api/getMessage').get(api.getMessage(bot));
router.route('/api/updateRule').post(api.updateRule(bot));
router.route('/dashboard').get(dash.get(io))
.post(dash.post(io));
router.route('/getMessage').get(api.getMessage(bot))
return router;
};

@ -23,11 +23,6 @@ const io = new Server(server);
var Childs = [];
server.listen(port, () =>
{
app.use('/', require('./routes/routes')(io));
console.log(`Http-Server UP`);
});
const bot = new Client({ intents: [
GatewayIntentBits.Guilds,
@ -54,10 +49,10 @@ const bot = new Client({ intents: [
Partials.Message
]
});
function login()
(function login()
{
bot.login(process.env.discord_token).catch(()=>{login()});
}
})()
function connectToDB()
{
@ -78,6 +73,12 @@ bot.on('ready', () =>
activities: [{ name: `!help`, type: ActivityType.Listening}],
status: 'online',
});
server.listen(port, () =>
{
app.use('/', require('./routes/routes')(io, bot));
console.log(`Http-Server UP`);
});
console.timeEnd('StartUp');
bot.guilds.cache.forEach(guild=>
{

@ -1,28 +0,0 @@
async function getChannelId(url)
{
return await fetch(url)
.then(handleResponse)
.then(handleData)
.catch(handleError);
function handleResponse(response)
{
return response.text();
}
function handleError(error)
{
console.log(error)
return error;
}
function handleData(data)
{
return data.split('https://www.youtube.com/feeds/videos.xml?channel_id=')[1].split('"')[0];
}
}
(async ()=>
{
var coiso = await getChannelId('https://www.youtube.com/@craftedworkshop');
console.log(coiso)
})()

@ -18,27 +18,53 @@
<div id="avatar"></div>
<h1><span id="userName">USERNAME</span></h1>
</div>
<table id="guilds">
<tr>
<th>Guild</th>
<th>Has Rem?</th>
<th>Configure</th>
</tr>
</table>
<div id="Guilds">
</div>
<div class="popup hidden" id= 'popup'>
<i onclick="handleClose(this)" class="close material-symbols-outlined" id="close_bt">
cancel
</i>
<h3 id="guild">PLACEHOLDER</h3>
<h3 id="guild" class="guildname">PLACEHOLDER</h3>
<p>Activate Music:
<span class="material-symbols-outlined" id="music">check_box_outline_blank</span></p>
<p>Activate Strikes:
<span class="material-symbols-outlined" id="strikes">check_box_outline_blank </span>
</p>
<p id="RoleRules" onclick="handleToggleRules(this)">Role rules</p>
<div id="rules" class="rules hidden">
<i onclick="handleClose(this)" class="close material-symbols-outlined" id="close_bt">
cancel
</i>
<p id="newRole" onclick="addRule(this)">New Role</p>
<p id="ruleID" class="addRoleName">Role Name</p>
</div>
</div>
<div id="roleRuleWrapper"class="roleRuleWrapper hidden">
<i onclick="handleClose(this)" class="close material-symbols-outlined" id="close_bt2">
cancel
</i>
<h1 id="roleRule" class="roleRule"> New Rule </h1>
<p id="role" class="role"> Role ID:</p>
<p id='emoji' class="emoji"><img id='emojiImg'></img>Emoji ID:</p>
<p id="message" class="message"> Message ID:</p>
<input id ="messageID" class='message messageID'></input>
<input id ="roleID" class='role roleID'></input>
<input id = "emojiID" class ="emoji emojiID"></input>
<button id="change" class="bt" onclick='updateRule(this)'>Change</button>
</div>
<!--
RoleRules
Channels
Feeds
-->
</div>
</body>

Loading…
Cancel
Save