mirror of
https://github.com/ION606/selmer-bot-website.git
synced 2026-05-14 22:16:54 +00:00
(fixed?) the issue with adding servers
This commit is contained in:
@@ -0,0 +1,232 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Selmer Bot Web Dashboard</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background:#000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#load {
|
||||||
|
position:absolute;
|
||||||
|
width:600px;
|
||||||
|
height:36px;
|
||||||
|
left:50%;
|
||||||
|
top:40%;
|
||||||
|
margin-left:-300px;
|
||||||
|
overflow:visible;
|
||||||
|
-webkit-user-select:none;
|
||||||
|
-moz-user-select:none;
|
||||||
|
-ms-user-select:none;
|
||||||
|
user-select:none;
|
||||||
|
cursor:default;
|
||||||
|
}
|
||||||
|
|
||||||
|
#load div {
|
||||||
|
position:absolute;
|
||||||
|
width:20px;
|
||||||
|
height:36px;
|
||||||
|
opacity:0;
|
||||||
|
font-family:Helvetica, Arial, sans-serif;
|
||||||
|
animation:move 2s linear infinite;
|
||||||
|
-o-animation:move 2s linear infinite;
|
||||||
|
-moz-animation:move 2s linear infinite;
|
||||||
|
-webkit-animation:move 2s linear infinite;
|
||||||
|
transform:rotate(180deg);
|
||||||
|
-o-transform:rotate(180deg);
|
||||||
|
-moz-transform:rotate(180deg);
|
||||||
|
-webkit-transform:rotate(180deg);
|
||||||
|
color:#35C4F0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#load div:nth-child(2) {
|
||||||
|
animation-delay:0.2s;
|
||||||
|
-o-animation-delay:0.2s;
|
||||||
|
-moz-animation-delay:0.2s;
|
||||||
|
-webkit-animation-delay:0.2s;
|
||||||
|
}
|
||||||
|
#load div:nth-child(3) {
|
||||||
|
animation-delay:0.4s;
|
||||||
|
-o-animation-delay:0.4s;
|
||||||
|
-webkit-animation-delay:0.4s;
|
||||||
|
-webkit-animation-delay:0.4s;
|
||||||
|
}
|
||||||
|
#load div:nth-child(4) {
|
||||||
|
animation-delay:0.6s;
|
||||||
|
-o-animation-delay:0.6s;
|
||||||
|
-moz-animation-delay:0.6s;
|
||||||
|
-webkit-animation-delay:0.6s;
|
||||||
|
}
|
||||||
|
#load div:nth-child(5) {
|
||||||
|
animation-delay:0.8s;
|
||||||
|
-o-animation-delay:0.8s;
|
||||||
|
-moz-animation-delay:0.8s;
|
||||||
|
-webkit-animation-delay:0.8s;
|
||||||
|
}
|
||||||
|
#load div:nth-child(6) {
|
||||||
|
animation-delay:1s;
|
||||||
|
-o-animation-delay:1s;
|
||||||
|
-moz-animation-delay:1s;
|
||||||
|
-webkit-animation-delay:1s;
|
||||||
|
}
|
||||||
|
#load div:nth-child(7) {
|
||||||
|
animation-delay:1.2s;
|
||||||
|
-o-animation-delay:1.2s;
|
||||||
|
-moz-animation-delay:1.2s;
|
||||||
|
-webkit-animation-delay:1.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes move {
|
||||||
|
0% {
|
||||||
|
left:0;
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
35% {
|
||||||
|
left: 41%;
|
||||||
|
-moz-transform:rotate(0deg);
|
||||||
|
-webkit-transform:rotate(0deg);
|
||||||
|
-o-transform:rotate(0deg);
|
||||||
|
transform:rotate(0deg);
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
65% {
|
||||||
|
left:59%;
|
||||||
|
-moz-transform:rotate(0deg);
|
||||||
|
-webkit-transform:rotate(0deg);
|
||||||
|
-o-transform:rotate(0deg);
|
||||||
|
transform:rotate(0deg);
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
left:100%;
|
||||||
|
-moz-transform:rotate(-180deg);
|
||||||
|
-webkit-transform:rotate(-180deg);
|
||||||
|
-o-transform:rotate(-180deg);
|
||||||
|
transform:rotate(-180deg);
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-moz-keyframes move {
|
||||||
|
0% {
|
||||||
|
left:0;
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
35% {
|
||||||
|
left:41%;
|
||||||
|
-moz-transform:rotate(0deg);
|
||||||
|
transform:rotate(0deg);
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
65% {
|
||||||
|
left:59%;
|
||||||
|
-moz-transform:rotate(0deg);
|
||||||
|
transform:rotate(0deg);
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
left:100%;
|
||||||
|
-moz-transform:rotate(-180deg);
|
||||||
|
transform:rotate(-180deg);
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes move {
|
||||||
|
0% {
|
||||||
|
left:0;
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
35% {
|
||||||
|
left:41%;
|
||||||
|
-webkit-transform:rotate(0deg);
|
||||||
|
transform:rotate(0deg);
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
65% {
|
||||||
|
left:59%;
|
||||||
|
-webkit-transform:rotate(0deg);
|
||||||
|
transform:rotate(0deg);
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
left:100%;
|
||||||
|
-webkit-transform:rotate(-180deg);
|
||||||
|
transform:rotate(-180deg);
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-o-keyframes move {
|
||||||
|
0% {
|
||||||
|
left:0;
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
35% {
|
||||||
|
left:41%;
|
||||||
|
-o-transform:rotate(0deg);
|
||||||
|
transform:rotate(0deg);
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
65% {
|
||||||
|
left:59%;
|
||||||
|
-o-transform:rotate(0deg);
|
||||||
|
transform:rotate(0deg);
|
||||||
|
opacity:1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
left:100%;
|
||||||
|
-o-transform:rotate(-180deg);
|
||||||
|
transform:rotate(-180deg);
|
||||||
|
opacity:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.onload = () => {
|
||||||
|
var guildId = window.location.href;
|
||||||
|
guildId = guildId.split('guild_id=')[1];
|
||||||
|
guildId = guildId.split('&')[0];
|
||||||
|
const sid = window.localStorage.getItem('sessionId');
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('post', 'https://www.selmerbot.com/joinedGuild', true);
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||||
|
xhr.setRequestHeader('serverNumber', guildId);
|
||||||
|
xhr.setRequestHeader('sessionid', sid);
|
||||||
|
xhr.onloadend = (e) => {
|
||||||
|
if (xhr.response == 'OK') {
|
||||||
|
window.location.href = 'dashboard';
|
||||||
|
} else {
|
||||||
|
// alert("Uh oh, an error has occured\nPlease try again!");
|
||||||
|
// window.location.href = 'myGuilds';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="align-content: center;">
|
||||||
|
<div id="load">
|
||||||
|
<div>G</div>
|
||||||
|
<div>N</div>
|
||||||
|
<div>I</div>
|
||||||
|
<div>D</div>
|
||||||
|
<div>A</div>
|
||||||
|
<div>O</div>
|
||||||
|
<div>L</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="bottom: 0; color: rgb(65, 0, 185); position: absolute;">Animation by Dissimulate <a href="https://codepen.io/dissimulate">https://codepen.io/dissimulate</a></footer>
|
||||||
|
<!-- Get the session id, send it to the main server, then redirect to the dashboard -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+10
-2
@@ -58,7 +58,8 @@
|
|||||||
function getSessionData() {
|
function getSessionData() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var xhrsess = new XMLHttpRequest();
|
var xhrsess = new XMLHttpRequest();
|
||||||
xhrsess.open('post', 'https://www.selmerbot.com/getSessionInfo/', true);
|
// xhrsess.open('post', 'https://www.selmerbot.com/getSessionInfo/', true);
|
||||||
|
xhrsess.open('post', 'http://localhost:53134/getSessionInfo/', true);
|
||||||
xhrsess.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
xhrsess.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||||
xhrsess.setRequestHeader('session', window.localStorage.getItem('sessionId'));
|
xhrsess.setRequestHeader('session', window.localStorage.getItem('sessionId'));
|
||||||
|
|
||||||
@@ -131,7 +132,14 @@
|
|||||||
// imagem.classList.add('serverImgOut');
|
// imagem.classList.add('serverImgOut');
|
||||||
imagem.className = 'serverImgOut';
|
imagem.className = 'serverImgOut';
|
||||||
imagem.onclick = function() {
|
imagem.onclick = function() {
|
||||||
window.open('https://discord.com/oauth2/authorize?client_id=926551095352901632&scope=applications.commands+bot&permissions=549755289087');
|
var url;
|
||||||
|
//Open a new window with the invite. Once the invite is processed, send request to the server to update the db (toggle inServer to true?)
|
||||||
|
if (window.location.href.indexOf('localhost') != -1) {
|
||||||
|
url = 'https://discord.com/api/oauth2/authorize?client_id=944046902415093760&permissions=549755289087&redirect_uri=http%3A%2F%2Flocalhost%3A53134%2FjoinedGuild&response_type=code&scope=rpc%20bot%20applications.commands'
|
||||||
|
} else {
|
||||||
|
url = 'https://discord.com/api/oauth2/authorize?client_id=944046902415093760&permissions=549755289087&redirect_uri=https%3A%2F%2Fwww.selmerbot.com%2FjoinedGuild&scope=bot%20applications.commands'
|
||||||
|
}
|
||||||
|
window.open(url);
|
||||||
}//OPEN A NEW WINDOW WITH SERVER INVITE
|
}//OPEN A NEW WINDOW WITH SERVER INVITE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,10 +52,69 @@ async function getJSONResponse(body) {
|
|||||||
return JSON.parse(fullBody);
|
return JSON.parse(fullBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function setCurrentServer(sid, id) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
if (id) {
|
||||||
|
const obj = {};
|
||||||
|
const arr = {text: [], voice: []};
|
||||||
|
const guild = bot.guilds.cache.get(id);
|
||||||
|
|
||||||
|
const roles = [];
|
||||||
|
guild.roles.cache.filter((role) => { return(!role.managed) }).forEach((role) => {
|
||||||
|
let newObj = {};
|
||||||
|
newObj.Id = role.id;
|
||||||
|
newObj.name = role.name;
|
||||||
|
newObj.color = role.hexColor;
|
||||||
|
|
||||||
|
roles.push(newObj);
|
||||||
|
});
|
||||||
|
|
||||||
|
const channels = guild.channels.cache;
|
||||||
|
channels.forEach((channel) => {
|
||||||
|
const type = channel.type;
|
||||||
|
if (type == 'GUILD_TEXT') {
|
||||||
|
arr.text.push({ name: channel.name, id: channel.id });
|
||||||
|
} else if (type == 'GUILD_VOICE') {
|
||||||
|
arr.voice.push({ name: channel.name, id: channel.id });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connection.then((client) => {
|
||||||
|
const dbo = client.db(id).collection('SETUP');
|
||||||
|
dbo.find().toArray(async (err, docs) => {
|
||||||
|
const m = new Map();
|
||||||
|
m.set('Id', id);
|
||||||
|
|
||||||
|
await Promise.all(docs.map(async (doc) => {
|
||||||
|
m.set(doc._id, doc);
|
||||||
|
})).then(() => {
|
||||||
|
obj['Id'] = id;
|
||||||
|
obj['roles'] = JSON.stringify(roles);
|
||||||
|
obj['channels'] = JSON.stringify(arr);
|
||||||
|
obj['serverSettings'] = JSON.stringify(Object.fromEntries(m));
|
||||||
|
|
||||||
|
const dbo = client.db('main').collection('sessions');
|
||||||
|
dbo.updateOne({ sessionId: sid }, {$set: { currentServer: JSON.stringify(obj) }});
|
||||||
|
resolve(200);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
// app.use(express.json());
|
// app.use(express.json());
|
||||||
app.use(express.static('/assets'));
|
app.use(express.static('/assets'));
|
||||||
app.use('/CSS', express.static('./CSS'));
|
app.use('/CSS', express.static('./CSS'));
|
||||||
|
app.use('/scripts', express.static('./scripts'));
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
|
||||||
@@ -160,59 +219,12 @@ app.get('/getChannels', async (req, res) => {
|
|||||||
|
|
||||||
//Headers: servernumber, sessionid
|
//Headers: servernumber, sessionid
|
||||||
app.post('/setCurrentServer', async (req, res) => {
|
app.post('/setCurrentServer', async (req, res) => {
|
||||||
try {
|
setCurrentServer().then((code) => {
|
||||||
const id = req.headers.servernumber;
|
res.sendStatus(code);
|
||||||
|
}).catch((err) => {
|
||||||
if (id) {
|
|
||||||
const obj = {};
|
|
||||||
const arr = {text: [], voice: []};
|
|
||||||
const guild = bot.guilds.cache.get(id);
|
|
||||||
|
|
||||||
const roles = [];
|
|
||||||
guild.roles.cache.filter((role) => { return(!role.managed) }).forEach((role) => {
|
|
||||||
let newObj = {};
|
|
||||||
newObj.Id = role.id;
|
|
||||||
newObj.name = role.name;
|
|
||||||
newObj.color = role.hexColor;
|
|
||||||
|
|
||||||
roles.push(newObj);
|
|
||||||
});
|
|
||||||
|
|
||||||
const channels = guild.channels.cache;
|
|
||||||
channels.forEach((channel) => {
|
|
||||||
const type = channel.type;
|
|
||||||
if (type == 'GUILD_TEXT') {
|
|
||||||
arr.text.push({ name: channel.name, id: channel.id });
|
|
||||||
} else if (type == 'GUILD_VOICE') {
|
|
||||||
arr.voice.push({ name: channel.name, id: channel.id });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
connection.then((client) => {
|
|
||||||
const dbo = client.db(id).collection('SETUP');
|
|
||||||
dbo.find().toArray(async (err, docs) => {
|
|
||||||
const m = new Map();
|
|
||||||
m.set('Id', id);
|
|
||||||
|
|
||||||
await Promise.all(docs.map(async (doc) => {
|
|
||||||
m.set(doc._id, doc);
|
|
||||||
})).then(() => {
|
|
||||||
obj['Id'] = id;
|
|
||||||
obj['roles'] = JSON.stringify(roles);
|
|
||||||
obj['channels'] = JSON.stringify(arr);
|
|
||||||
obj['serverSettings'] = JSON.stringify(Object.fromEntries(m));
|
|
||||||
|
|
||||||
const dbo = client.db('main').collection('sessions');
|
|
||||||
dbo.updateOne({ sessionId: req.headers.sessionid }, {$set: { currentServer: JSON.stringify(obj) }});
|
|
||||||
res.sendStatus(200);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -293,7 +305,37 @@ app.get('/calendar', async (req, res) => {
|
|||||||
|
|
||||||
app.get('/team', async (req, res) => {
|
app.get('/team', async (req, res) => {
|
||||||
return res.sendFile("team.html", { root: 'HTML' });
|
return res.sendFile("team.html", { root: 'HTML' });
|
||||||
})
|
});
|
||||||
|
|
||||||
|
app.get('/joinedGuild', async (req, res) => {
|
||||||
|
res.sendFile('joinedGuild.html', { root: 'HTML' });
|
||||||
|
});
|
||||||
|
|
||||||
|
app.post('/joinedGuild', async (req, res) => {
|
||||||
|
// res.sendFile('joinedGuild.html', { root: 'HTML' });
|
||||||
|
const { headers } = req;
|
||||||
|
const { servernumber, sessionid } = headers;
|
||||||
|
|
||||||
|
connection.then((client) => {
|
||||||
|
const dbo = client.db('main').collection('sessions');
|
||||||
|
dbo.find().toArray((err, docs) => {
|
||||||
|
const guilds = JSON.parse(docs[0].guilds);
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (let i = 0; i < guilds.length; i++) {
|
||||||
|
if (guilds[i].id == servernumber) {
|
||||||
|
guilds[i].inServer = true;
|
||||||
|
setCurrentServer(sessionid, servernumber);
|
||||||
|
return res.sendStatus(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
res.sendStatus(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// I'm not sure this will contain any of the html scripts
|
||||||
|
// This is because every file's functions (even sendData) are unique to that file
|
||||||
Reference in New Issue
Block a user