mirror of
https://github.com/ION606/selmer-bot-website.git
synced 2026-05-14 22:16:54 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
config.json
|
||||
.env
|
||||
node_modules
|
||||
index - old.html
|
||||
makefile
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 131 KiB |
+430
@@ -0,0 +1,430 @@
|
||||
<!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>
|
||||
|
||||
<link rel="shortcut icon" href="https://github.com/ION606/selmer-bot-website/blob/main/assets/favicon.ico" type="image/x-icon">
|
||||
<script src="https://kit.fontawesome.com/728e740903.js" crossorigin="anonymous"></script>
|
||||
|
||||
<style>
|
||||
html { width:100%; height:100%; margin:0; padding:0; }
|
||||
|
||||
body {
|
||||
/* background-color: rgb(4, 4, 85); */
|
||||
background-color: rgb(41, 42, 48);
|
||||
width:100%; height:100%; margin:0; padding:0;
|
||||
}
|
||||
|
||||
/* .dropdown a:hover { background-color: #ddd; } */
|
||||
|
||||
.show { display: block; }
|
||||
|
||||
.hide { display: none; }
|
||||
|
||||
|
||||
.jumpButton {
|
||||
/* color: #ffffff; */
|
||||
font-size: 15px;
|
||||
border: 1px solid #000000;
|
||||
width: 200px;
|
||||
height: 40px;
|
||||
cursor: pointer;
|
||||
align-self: center;
|
||||
background-color: rgb(2, 2, 192);
|
||||
}
|
||||
.jumpButton:hover {
|
||||
color: #2d63c8;
|
||||
/* background-color: #ffffff; */
|
||||
}
|
||||
|
||||
|
||||
.loadingscreen {
|
||||
height: 90vh;
|
||||
background-color: bisque;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: rgb(69, 11, 102);
|
||||
height: 50px;
|
||||
border-width: 1px;
|
||||
border-style: double;
|
||||
}
|
||||
|
||||
#right {
|
||||
float: right;
|
||||
margin-right: 50px;
|
||||
}
|
||||
|
||||
.box {
|
||||
font-size: 20px;
|
||||
height: 20px;
|
||||
width: auto;
|
||||
margin-bottom: 15px;
|
||||
margin-right: 70px;
|
||||
padding: 5px;
|
||||
border: 1px solid black;
|
||||
clear: both;
|
||||
align-content: center;
|
||||
float: right;
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
.statusdiv {
|
||||
border-style: dashed;
|
||||
border-color: rgb(247, 189, 0);
|
||||
width: 130px;
|
||||
height: 100px;
|
||||
margin-top: 20px;
|
||||
float: right;
|
||||
margin-right: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.saved {
|
||||
background-color: rgb(11, 184, 11);
|
||||
}
|
||||
.saving {
|
||||
background-color: orange;
|
||||
}
|
||||
.failed {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
|
||||
.buttonsmainbar {
|
||||
background-color: green;
|
||||
width: 200px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.btnmain {
|
||||
background-color: rgb(0, 0, 0);
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background-color: #42424b;
|
||||
width: 11%;
|
||||
position: fixed;
|
||||
top: 53px;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
border: 0px;
|
||||
border-right: 2px;
|
||||
border-color: black;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
.btnside {
|
||||
color: #ffffff;
|
||||
background-color: #42424b;
|
||||
font-size: 19px;
|
||||
/* border: 2px solid #000000; */
|
||||
outline: none;
|
||||
border: none;
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btnside:hover {
|
||||
color: #ffffff;
|
||||
background-color: #377aea;
|
||||
}
|
||||
|
||||
.wc {
|
||||
align-content: center;
|
||||
align-self: center;
|
||||
color: white;
|
||||
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.lg {
|
||||
align-content: center;
|
||||
align-self: center;
|
||||
color: white;
|
||||
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
|
||||
/* SUBMIT BUTTON START */
|
||||
.submitButton{
|
||||
position: relative;
|
||||
background-color: black;
|
||||
border-radius: 4em;
|
||||
font-size: 16px;
|
||||
color: white;
|
||||
padding: 0.8em 1.8em;
|
||||
cursor:pointer;
|
||||
user-select:none;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
transition-duration: 0.4s;
|
||||
-webkit-transition-duration: 0.4s; /* Safari */
|
||||
}
|
||||
|
||||
.submitButton:hover {
|
||||
transition-duration: 0.1s;
|
||||
background-color: #3A3A3A;
|
||||
}
|
||||
|
||||
.submitButton:after {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
border-radius: 4em;
|
||||
left: 0;
|
||||
top:0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
transition: all 0.5s;
|
||||
box-shadow: 0 0 10px 40px white;
|
||||
}
|
||||
|
||||
.submitButton:active:after {
|
||||
box-shadow: 0 0 0 0 white;
|
||||
position: absolute;
|
||||
border-radius: 4em;
|
||||
left: 0;
|
||||
top:0;
|
||||
opacity: 1;
|
||||
transition: 0s;
|
||||
}
|
||||
|
||||
.submitButton:active {
|
||||
top: 1px;
|
||||
}
|
||||
/* SUBMIT BUTTON END */
|
||||
|
||||
.logoutbtn {
|
||||
margin-top: 14px;
|
||||
scale: 1.7;
|
||||
}
|
||||
|
||||
.logoutbtn:hover {
|
||||
cursor: pointer;
|
||||
color: red;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<script>
|
||||
//Maybe pre-load the channels in the server into local storage for accessing when chosing the welcome/logging channels?
|
||||
window.onload = () => {
|
||||
var serverSettings = JSON.parse(window.localStorage.getItem('serverInfo'));
|
||||
|
||||
//Load the channels serverSettings.Id
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('get', 'https://selmer-bot-website.herokuapp.com/getChannels/', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xhr.setRequestHeader('serverNumber', serverSettings.Id);
|
||||
xhr.onloadend = (e) => {
|
||||
window.localStorage.setItem('channels', (xhr.response));
|
||||
document.getElementById('body').classList.replace('hide', 'show');
|
||||
|
||||
//Welcome section
|
||||
let wc = serverSettings.WELCOME.welcomechannel || '';
|
||||
let wm = serverSettings.WELCOME.welcomemessage || '';
|
||||
document.getElementById('wc').setAttribute('value', wc);
|
||||
document.getElementById('wm').setAttribute('value', wm);
|
||||
|
||||
//Logging section ,"LOG":{"_id":"LOG","keepLogs":false,"logchannel":null,"severity":0}}
|
||||
let kl = serverSettings.LOG.keepLogs || false;
|
||||
let lc = serverSettings.LOG.logchannel || '';
|
||||
let ls = serverSettings.LOG.severity || 0;
|
||||
|
||||
document.getElementById('kl').checked = kl;
|
||||
document.getElementById('lc').setAttribute('value', lc);
|
||||
|
||||
// document.getElementById('ls').children[ls].checked = true; //Doesn't work
|
||||
}
|
||||
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
|
||||
function logout() {
|
||||
window.localStorage.clear();
|
||||
window.location.href = 'index.html';
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function loadWelcomePage() {
|
||||
document.getElementById('welcome').classList.replace('hide', 'show');
|
||||
}
|
||||
|
||||
|
||||
function loadLoggingPage() {
|
||||
document.getElementById('log').classList.replace('hide', 'show');
|
||||
}
|
||||
|
||||
|
||||
function divChange(c1) {
|
||||
// document.getElementById("mainDropdown").classList.toggle("show");
|
||||
var divchildren = document.getElementById('inputs').children;
|
||||
|
||||
//Hide the divs we don't need
|
||||
for (let i = 0; i < divchildren.length; i++) {
|
||||
var d2 = document.getElementById(divchildren[i].id);
|
||||
if (!d2.classList.contains('hide')) { d2.classList.add('hide'); }
|
||||
}
|
||||
|
||||
//Show the div we want
|
||||
var d1 = document.getElementById(c1);
|
||||
d1.classList.toggle("hide");
|
||||
}
|
||||
|
||||
|
||||
function sendData(event, inp) {
|
||||
event.preventDefault();
|
||||
|
||||
//Change saving status
|
||||
var b = document.getElementById('savstat');
|
||||
b.classList.replace('saved', 'saving');
|
||||
b.innerText = 'SAVING';
|
||||
|
||||
var serverSettings = JSON.parse(window.localStorage.getItem('serverInfo'));
|
||||
|
||||
if (inp.inp == 'logs') {
|
||||
const ls = document.getElementsByName('ls');
|
||||
var sevname = '';
|
||||
for (i in ls) {
|
||||
if (ls[i].checked) { sevname = ls[i].id.substring(3); }
|
||||
}
|
||||
|
||||
const sevlist = ['none', 'low', 'meduim', 'high']
|
||||
serverSettings.LOG.severity = sevlist.indexOf(sevname);
|
||||
serverSettings.LOG.logchannel = document.getElementById('lc').value || null;
|
||||
|
||||
let kl = false;
|
||||
if (document.getElementById('kl').checked) {
|
||||
kl = true;
|
||||
}
|
||||
serverSettings.LOG.keepLogs = kl;
|
||||
} else {
|
||||
const wc = document.getElementById('wc').value || null;
|
||||
const wm = document.getElementById('wm').value || null;
|
||||
|
||||
serverSettings.WELCOME.welcomechannel = wc;
|
||||
serverSettings.WELCOME.welcomemessage = wm;
|
||||
}
|
||||
|
||||
//Send the data to the server
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('post', 'https://selmer-bot-website.herokuapp.com/sendData/', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xhr.setRequestHeader('serverSettings', JSON.stringify(serverSettings));
|
||||
|
||||
xhr.onloadend = (e) => {
|
||||
if (xhr.response == 'DONE') {
|
||||
b.classList.replace('saving', 'saved');
|
||||
b.innerText = 'SAVED';
|
||||
window.localStorage.setItem('serverInfo', JSON.stringify(serverSettings));
|
||||
} else {
|
||||
b.classList.replace('saving', 'failed');
|
||||
b.innerText = 'FAILED';
|
||||
}
|
||||
}
|
||||
|
||||
xhr.send(JSON.stringify(serverSettings));
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body id="body">
|
||||
<!-- <center> -->
|
||||
<div class="navbar">
|
||||
<span style="padding-left: 50px;"></span>
|
||||
<a href="index.html" style="color: white"><i class="fa-solid fa-house-chimney", alt="Home" style="scale: 2; margin-top: 20px;"></i></a>
|
||||
|
||||
<span style="padding-left:50px;">
|
||||
<a href="myGuilds.html"><i class="fa-solid fa-server" alt="Servers" style="scale: 2; color: rgb(11, 189, 189);"></i></a>
|
||||
</span>
|
||||
|
||||
<span style="padding-left:50px;"></span>
|
||||
<a href="https://github.com/ION606/selmerBot/wiki" target="_blank"><i class="fa-solid fa-book" style="scale: 2; color: white;" alt="WIKI"></i></a>
|
||||
|
||||
<span style="padding-left:50px;"></span>
|
||||
<a href="premium.html"><i class="fa-solid fa-crown" style="scale: 2; color: gold;" alt="PREMIUM"></i></a>
|
||||
|
||||
<!-- <button>Home</button> -->
|
||||
<span id="right">
|
||||
<button onclick="logout()" class="logoutbtn"><i class="fa-solid fa-arrow-right-from-bracket" alt="Log Out"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- </center> -->
|
||||
<div class="statusdiv">
|
||||
<h1 style="color: white; margin-bottom: 10px; margin-top: 10px;">STATUS</h1>
|
||||
<div id="savstat" class="box saved">SAVED</div>
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
<div id="buttons" class="buttonsmainbar">
|
||||
<button onclick="divChange('welcome')" class="btnside">Welcome</button>
|
||||
<button onclick="divChange('log')" class="btnside">Logging</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- EVERYTHING NOT SIDEBAR -->
|
||||
<div style="margin-left:15%">
|
||||
|
||||
<div id="inputs">
|
||||
<div id="welcome", class="hide wc" style="margin-top: 20px;">
|
||||
<form>
|
||||
<label for="wc">Welcome Channel Name:</label>
|
||||
<input type="text" id="wc" name="wc"><br><br>
|
||||
|
||||
<label for="wm">Welcome Message:</label>
|
||||
<input type="text" id="wm" name="wm"><br><br>
|
||||
|
||||
<!-- <label for="welcomebanner">Last name:</label>
|
||||
<input type="text" id="wb" name="wb"><br><br> -->
|
||||
|
||||
<input type="submit" value="Submit", class="submitButton" onclick="sendData(event, { 'inp': 'welcome' })">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- <template> -->
|
||||
<div id="log", class="hide lg">
|
||||
<button style="margin-top: 30px; margin-bottom: 20px; font-size: 20px; align-self: right;" onclick="alert('When setting the log severity, setting the tier will also include all higher tiers\nFor example, using !setup log_severity none will log things from every severity')">Help</button>
|
||||
<form>
|
||||
<label for="kl">Keep Logs?</label>
|
||||
<input type="checkbox" id="kl" name="kl"><br><br>
|
||||
|
||||
<label for="lc">Logging Channel Name:</label>
|
||||
<input type="text" id="lc" name="lc"><br><br>
|
||||
|
||||
<p>Log Severity</p>
|
||||
<label for="ls-none">None</label>
|
||||
<input type="radio" id="ls-none" name="ls"><br><br>
|
||||
|
||||
<label for="ls-low">Low</label>
|
||||
<input type="radio" id="ls-low" name="ls"><br><br>
|
||||
|
||||
<label for="ls-meduim">Medium</label>
|
||||
<input type="radio" id="ls-meduim" name="ls"><br><br>
|
||||
|
||||
<label for="ls-high">High</label>
|
||||
<input type="radio" id="ls-high" name="ls"><br><br>
|
||||
|
||||
|
||||
<input type="submit" value="Submit", class="submitButton" onclick="sendData(event, { 'inp': 'logs' })">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </template> -->
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Selmer Bot Web Dashboard</title>
|
||||
|
||||
<link rel="shortcut icon" href="https://github.com/ION606/selmer-bot-website/blob/main/assets/favicon.ico" type="image/x-icon">
|
||||
<script src="https://kit.fontawesome.com/728e740903.js" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- <script type="text/javascript" src="main.js"></script> -->
|
||||
|
||||
<style>
|
||||
html { width:100%; height:100%; margin:0; padding:0; }
|
||||
|
||||
body {
|
||||
background-color: rgb(41, 42, 48);
|
||||
width:100%; height:100%; margin:0; padding:0;
|
||||
}
|
||||
|
||||
.loginbtn {
|
||||
color: #ffffff;
|
||||
background-color: #2909c6;
|
||||
font-size: 19px;
|
||||
border: 2px solid #000000;
|
||||
padding: 15px;
|
||||
cursor: pointer;
|
||||
width: 200px;
|
||||
}
|
||||
.loginbtn:hover {
|
||||
color: #ffffff;
|
||||
background-color: #377aea;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.tooltip .tooltiptext {
|
||||
visibility: hidden;
|
||||
padding: 0.25em 0.5em;
|
||||
background-color: black;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
border-radius: 0.25em;
|
||||
white-space: nowrap;
|
||||
|
||||
/* Position the tooltip */
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top: 100%;
|
||||
left: 100%;
|
||||
transition-property: visibility;
|
||||
transition-delay: 0s;
|
||||
}
|
||||
|
||||
.tooltip:hover .tooltiptext {
|
||||
visibility: visible;
|
||||
transition-delay: 0.3s;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: rgb(69, 11, 102);
|
||||
height: 50px;
|
||||
border-width: 1px;
|
||||
border-style: double;
|
||||
}
|
||||
|
||||
#right {
|
||||
float: right;
|
||||
margin-right: 50px;
|
||||
}
|
||||
|
||||
.logoutbtn {
|
||||
margin-top: 14px;
|
||||
scale: 1.7;
|
||||
}
|
||||
|
||||
.logoutbtn:hover {
|
||||
cursor: pointer;
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> (no github icon so...) -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
|
||||
<script>
|
||||
function generateRandomString() {
|
||||
let randomString = '';
|
||||
const randomNumber = Math.floor(Math.random() * 10);
|
||||
|
||||
for (let i = 0; i < 20 + randomNumber; i++) {
|
||||
randomString += String.fromCharCode(33 + Math.floor(Math.random() * 94));
|
||||
}
|
||||
|
||||
return randomString;
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
const fragment = new URLSearchParams(window.location.hash.slice(1));
|
||||
const [accessToken, tokenType, state] = [fragment.get('access_token'), fragment.get('token_type'), fragment.get('state')];
|
||||
|
||||
if (!accessToken && !window.localStorage.getItem('serverInfo')) {
|
||||
const randomString = generateRandomString();
|
||||
localStorage.setItem('oauth-state', randomString);
|
||||
document.getElementById('guildslink').href = '';
|
||||
document.getElementById('guildslink').style = 'cursor: no-drop;';
|
||||
|
||||
document.getElementById('login').href += `&state=${encodeURIComponent(btoa(randomString))}`;
|
||||
return document.getElementById('login').style.display = 'block';
|
||||
} else if (!accessToken && window.localStorage.getItem('serverInfo')) {
|
||||
//Maybe do something?
|
||||
}
|
||||
|
||||
if (localStorage.getItem('oauth-state') !== atob(decodeURIComponent(state))) {
|
||||
console.log('You may have been click-jacked!');
|
||||
}
|
||||
|
||||
fetch('https://discord.com/api/users/@me', {
|
||||
headers: {
|
||||
authorization: `${tokenType} ${accessToken}`,
|
||||
},
|
||||
})
|
||||
.then(result => result.json())
|
||||
.then(response => {
|
||||
// document.getElementById('TEMP').innerText = response.toString();
|
||||
// console.log(response);
|
||||
const { id, username, discriminator } = response;
|
||||
window.localStorage.setItem('Id', id);
|
||||
// console.log(guilds);
|
||||
// document.getElementById('info').innerText += ` ${username}#${discriminator}`;
|
||||
|
||||
// window.location = `https://selmer-bot-website.herokuapp.com/user?id=${id}`;
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
//Guilds section
|
||||
fetch('https://discord.com/api/users/@me/guilds', {
|
||||
// method: 'POST',
|
||||
headers: {
|
||||
authorization: `${tokenType} ${accessToken}`,
|
||||
}
|
||||
}).then(response => {
|
||||
response.json().then((result) => {
|
||||
|
||||
const owned = result.filter((inp) => { return (inp.owner); });
|
||||
// window.localStorage.setItem('guilds', owned);
|
||||
|
||||
alert('Loading, please hold!\nps - You can close this alert :)');
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('post', 'https://selmer-bot-website.herokuapp.com/user/', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xhr.setRequestHeader('guilds', JSON.stringify(owned));
|
||||
xhr.setRequestHeader('userId', window.localStorage.getItem('Id'));
|
||||
|
||||
xhr.onloadend = (e) => { window.localStorage.setItem('guilds', (JSON.stringify(xhr.response))); window.location = 'https://selmer-bot-website.herokuapp.com/myGuilds.html'; }
|
||||
xhr.send(JSON.stringify(owned));
|
||||
}).then((r) => {
|
||||
|
||||
})
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//Get the redirect link <!-- NOTE: "response_type=token" ALWAYS!!! https://selmer-bot-website.herokuapp.com -->
|
||||
function getAPIRedirect() {
|
||||
if (window.location.href.indexOf('localhost') != -1) {
|
||||
alert(1);
|
||||
return 'https://discord.com/api/oauth2/authorize?client_id=926551095352901632&redirect_uri=http%3A%2F%2Flocalhost%3A53134%2F&response_type=token&scope=identify%20guilds';
|
||||
} else {
|
||||
return "https://discord.com/api/oauth2/authorize?client_id=944046902415093760&redirect_uri=https%3A%2F%2Fselmer-bot-website.herokuapp.com%2F&response_type=token&scope=identify%20guilds"
|
||||
}
|
||||
}
|
||||
|
||||
function logout() {
|
||||
window.localStorage.clear();
|
||||
window.location.href = 'index.html';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Nav Bar -->
|
||||
<div class="navbar">
|
||||
<span style="padding-left: 50px;"></span>
|
||||
<a href="index.html" style="color: white"><i class="fa-solid fa-house-chimney", alt="Home" style="scale: 2; margin-top: 20px;"></i></a>
|
||||
|
||||
<span style="padding-left:50px;">
|
||||
<a href="myGuilds.html" id="guildslink"><i class="fa-solid fa-server" alt="Servers" style="scale: 2; color: rgb(11, 189, 189);"></i></a>
|
||||
</span>
|
||||
|
||||
<span style="padding-left:50px;"></span>
|
||||
<a href="https://github.com/ION606/selmerBot/wiki" target="_blank"><i class="fa-solid fa-book" style="scale: 2; color: white;" alt="WIKI"></i></a>
|
||||
|
||||
<span style="padding-left:50px;"></span>
|
||||
<a href="premium.html"><i class="fa-solid fa-crown" style="scale: 2; color: gold;" alt="PREMIUM"></i></a>
|
||||
<!-- <button>Home</button> -->
|
||||
<span id="right">
|
||||
<button onclick="logout()" class="logoutbtn"><i class="fa-solid fa-arrow-right-from-bracket" alt="Log Out"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<center>
|
||||
<h1 style="color: white">SELMER BOT WEB DASHBOARD</h1>
|
||||
<button id="login" class="loginbtn" onclick="window.location = getAPIRedirect()">Log Into Dashboard</button>
|
||||
<div></div>
|
||||
|
||||
<a href="https://github.com/ION606/selmerBot" class="tooltip" style="cursor: pointer; margin-top: 10px;"><i class="fa fa-github" style="font-size:72px; color: #000000; margin: 10px;" alt="Github Repository"></i><span class="tooltiptext">Github Repository</span></a>
|
||||
|
||||
<div></div>
|
||||
<div class="tooltip">
|
||||
<a href="https://discord.com/oauth2/authorize?client_id=944046902415093760&scope=applications.commands+bot&permissions=549755289087" ><img src="https://cdn-icons-png.flaticon.com/512/5968/5968756.png" style="width: 72px; height: 72px; margin-top: 10px;" alt="Discord Invite Link"> <span class="tooltiptext">Discord Invite Link</span> </a>
|
||||
</div>
|
||||
|
||||
</center>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <script type="module" src="./main.js", type="application/json"></script> -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,185 @@
|
||||
// const { fetch } = require('undici');
|
||||
// const express = require('express');
|
||||
// const fetch = require('node-fetch');
|
||||
// const btoa = require('btoa');
|
||||
// const { clientId, clientSecret, port } = require('./config.json');
|
||||
import express from 'express';
|
||||
import fetch from 'node-fetch'
|
||||
import { MongoClient, ServerApiVersion } from 'mongodb'
|
||||
|
||||
//Bot section (PLACE IN ENV)
|
||||
import { Client, Intents } from 'discord.js';
|
||||
const token = process.env.token;
|
||||
const clientId = process.env.clientId;
|
||||
const clientSecret = process.env.clientSecret;
|
||||
const port = process.env.PORT || 3000;
|
||||
const mongouri = process.env.mongouri;
|
||||
|
||||
|
||||
const bot = new Client({
|
||||
intents: [
|
||||
Intents.FLAGS.GUILDS,
|
||||
Intents.FLAGS.GUILD_MESSAGES,
|
||||
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
|
||||
Intents.FLAGS.GUILD_VOICE_STATES,
|
||||
Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
|
||||
Intents.FLAGS.GUILD_PRESENCES,
|
||||
Intents.FLAGS.GUILD_MEMBERS,
|
||||
Intents.FLAGS.DIRECT_MESSAGES,
|
||||
Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
|
||||
Intents.FLAGS.DIRECT_MESSAGE_TYPING,
|
||||
],
|
||||
partials: [ 'CHANNEL' ]
|
||||
});
|
||||
|
||||
bot.on('ready', async () => {console.log('BOT RUNNING'); });
|
||||
bot.login(token);
|
||||
|
||||
|
||||
async function getJSONResponse(body) {
|
||||
let fullBody = '';
|
||||
|
||||
for await (const data of body) {
|
||||
fullBody += data.toString();
|
||||
}
|
||||
return JSON.parse(fullBody);
|
||||
}
|
||||
|
||||
const app = express();
|
||||
// app.use(express.json());
|
||||
|
||||
app.post('/user', async(request, response) => {
|
||||
|
||||
const guilds = JSON.parse(request.headers.guilds);
|
||||
|
||||
const id = request.headers.userid;
|
||||
|
||||
for (let i = 0; i < guilds.length; i ++) {
|
||||
const guild = bot.guilds.cache.get(guilds[i].id);
|
||||
|
||||
if (guild && guild.ownerId == id) {
|
||||
guilds[i].inServer = true;
|
||||
} else {
|
||||
guilds[i].inServer = false;
|
||||
}
|
||||
}
|
||||
|
||||
return response.send(guilds);
|
||||
return response.sendFile('myGuilds.html', { root: '.' });
|
||||
})
|
||||
|
||||
|
||||
app.get('/myGuilds.html', async (req, res) => {
|
||||
return res.sendFile('myGuilds.html', { root: '.' });
|
||||
});
|
||||
|
||||
|
||||
app.post('/getServer', async (req, res) => {
|
||||
const id = req.headers.servernumber;
|
||||
|
||||
//Get info
|
||||
const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
|
||||
client.connect(err => { console.error(err); });
|
||||
const dbo = client.db(id).collection('SETUP');
|
||||
dbo.find().toArray(async (err, docs) => {
|
||||
if (err) { return console.error(err); }
|
||||
|
||||
const m = new Map();
|
||||
m.set('Id', id);
|
||||
await Promise.all(docs.map(async (doc) => {
|
||||
m.set(doc._id, doc);
|
||||
|
||||
})).then(() => { res.send(JSON.stringify(Object.fromEntries(m))); })
|
||||
})
|
||||
|
||||
// return res.sendFile('myGuilds.html', { root: '.' });
|
||||
})
|
||||
|
||||
|
||||
app.get('/getChannels', async (req, res) => {
|
||||
const id = req.headers.servernumber;
|
||||
const channels = bot.guilds.cache.get(id).channels.cache;
|
||||
|
||||
const arr = {text: [], voice: []};
|
||||
|
||||
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 });
|
||||
}
|
||||
})
|
||||
|
||||
res.send(JSON.stringify(arr));
|
||||
});
|
||||
|
||||
|
||||
app.get('/dashboard.html', async (req, res) => {
|
||||
return res.sendFile('dashboard.html', { root: '.' });
|
||||
});
|
||||
|
||||
|
||||
app.get('/premium.html', async (req, res) => {
|
||||
return res.sendFile('premium.html', { root: '.' });
|
||||
});
|
||||
|
||||
app.get('/index.html', async (req, res) => {
|
||||
return res.sendFile('index.html', { root: '.' });
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.post('/sendData', async (req, res) => {
|
||||
try {
|
||||
const pref = JSON.parse(req.headers.serversettings);
|
||||
|
||||
const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
|
||||
client.connect(err => { console.error(err); });
|
||||
const dbo = client.db(pref.Id).collection('SETUP');
|
||||
|
||||
await dbo.updateOne({ _id: 'WELCOME' }, {$set: { welcomechannel: pref.WELCOME.welcomechannel, welcomemessage: pref.WELCOME.welcomemessage }});
|
||||
await dbo.updateOne({ _id: 'LOG' }, {$set: { keepLogs: pref.LOG.keepLogs, logchannel: pref.LOG.logchannel, severity: pref.LOG.severity }});
|
||||
|
||||
client.close().then(() => {
|
||||
res.send("DONE");
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.send("FAILED");
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/', async ({ query }, response) => {
|
||||
const { code } = query;
|
||||
|
||||
if (code) {
|
||||
try {
|
||||
await fetch('https://discord.com/api/oauth2/token', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
client_id: clientId,
|
||||
client_secret: clientSecret,
|
||||
code,
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri: `http://localhost`,
|
||||
scope: 'identify',
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
}).then(async response => {
|
||||
const oauthData = await getJSONResponse(response.body);
|
||||
// console.log(oauthData);
|
||||
}).catch(err => { console.error(err); });
|
||||
} catch (error) {
|
||||
// NOTE: An unauthorized token will not throw an error
|
||||
// tokenResponseData.statusCode will be 401
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
return response.sendFile('index.html', { root: '.' });
|
||||
});
|
||||
|
||||
app.listen(port, () => console.log(`App listening on port ${port}`));
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Selmer Bot Web Dashboard</title>
|
||||
|
||||
<link rel="shortcut icon" href="https://github.com/ION606/selmer-bot-website/blob/main/assets/favicon.ico" type="image/x-icon">
|
||||
|
||||
<style>
|
||||
html { width:100%; height:100%; margin:0; padding:0; }
|
||||
|
||||
body {
|
||||
background-color: rgb(41, 42, 48);
|
||||
width:100%; height:100%; margin:0; padding:0;
|
||||
}
|
||||
|
||||
.server {
|
||||
padding: 30px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
align-content: top;
|
||||
object-fit:scale-down;
|
||||
}
|
||||
.serverImgIn {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
object-fit:scale-down;
|
||||
border-radius:50%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.serverImgOut {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
object-fit:scale-down;
|
||||
border-radius:50%;
|
||||
cursor: pointer;
|
||||
filter: grayscale(100%);
|
||||
}
|
||||
|
||||
.serverRow {
|
||||
display: flex;
|
||||
-ms-flex-wrap: wrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
function createServerPage() {
|
||||
var tempPage = "<html>" + "HELLO WORLD, I'M A BLANK PAGE!" + "</html>";
|
||||
var w = window.open('TEMP');
|
||||
w.document.write(tempPage);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
window.onload = () => {
|
||||
const guilds = JSON.parse(JSON.parse(window.localStorage.getItem('guilds')));
|
||||
|
||||
var wrapper = document.getElementById('wrapper');
|
||||
|
||||
var row = document.createElement("servers_row");
|
||||
row.innerHTML = ""; // clear images
|
||||
row.classList.add('serverRow');
|
||||
|
||||
for (let i = 0; i < guilds.length; i++) {
|
||||
//New row every 10 servers
|
||||
if (i % 10 == 0) {
|
||||
wrapper.appendChild(row);
|
||||
row.innerHTML = "";
|
||||
row.classList.add('serverRow');
|
||||
}
|
||||
|
||||
var div = document.createElement("div");
|
||||
var imagem = document.createElement("img");
|
||||
var name = document.createElement("p");
|
||||
name.innerText = guilds[i].name;
|
||||
name.style = "color: white";
|
||||
|
||||
if (guilds[i].icon) {
|
||||
imagem.src = `https://cdn.discordapp.com/icons/${guilds[i].id}/${guilds[i].icon}.png`;
|
||||
} else {
|
||||
imagem.src = 'https://github.com/ION606/selmer-bot-website/blob/main/assets/circleOutline.png?raw=true';
|
||||
}
|
||||
|
||||
if (guilds[i].inServer) {
|
||||
// imagem.classList.add('serverImgIn');
|
||||
imagem.className = 'serverImgIn';
|
||||
|
||||
//OPEN A NEW WINDOW FOR SERVER EDITING
|
||||
imagem.onclick = function() {
|
||||
console.log('LOADING.....');
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('post', 'https://selmer-bot-website.herokuapp.com/getServer/', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xhr.setRequestHeader('serverNumber', guilds[i].id);
|
||||
xhr.onloadend = (e) => { window.localStorage.setItem('serverInfo', (xhr.response)); window.location = 'https://selmer-bot-website.herokuapp.com/dashboard.html'; }
|
||||
xhr.send();
|
||||
}
|
||||
} else {
|
||||
// imagem.classList.add('serverImgOut');
|
||||
imagem.className = 'serverImgOut';
|
||||
imagem.onclick = function() {
|
||||
window.open('https://discord.com/oauth2/authorize?client_id=926551095352901632&scope=applications.commands+bot&permissions=549755289087');
|
||||
}//OPEN A NEW WINDOW WITH SERVER INVITE
|
||||
|
||||
}
|
||||
|
||||
div.appendChild(imagem);
|
||||
div.appendChild(name);
|
||||
|
||||
div.classList.add('server');
|
||||
|
||||
row.appendChild(div);
|
||||
}
|
||||
|
||||
wrapper.appendChild(row);
|
||||
wrapper.appendChild(document.createElement('div'));
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<!-- PLACEHOLDER TEXT HERE -->
|
||||
<!-- <img id="1" src="https://cdn.discordapp.com/icons/930148608400035860/76aab371cf5393ee9ae56c7493c656d4.png" alt="" title="" style="cursor: pointer; border-radius: 50%; border: 3px solid rgb(106, 255, 170);" width="128" height="128"> -->
|
||||
</div>
|
||||
</body>
|
||||
@@ -0,0 +1 @@
|
||||
href="https://discord.com/api/oauth2/authorize?client_id=926551095352901632&redirect_uri=http%3A%2F%2Flocalhost%3A53134%2F&response_type=token&scope=identify"
|
||||
Generated
+2250
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "selmer-bot-website",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "ION606",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"btoa": "^1.2.1",
|
||||
"discord.js": "^13.8.1",
|
||||
"ejs": "^3.1.8",
|
||||
"express": "^4.18.1",
|
||||
"mongodb": "^4.8.0",
|
||||
"nginx": "^1.0.8",
|
||||
"node-fetch": "^3.2.9",
|
||||
"undici": "^5.8.0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
<!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>
|
||||
|
||||
<link rel="shortcut icon" href="https://github.com/ION606/selmer-bot-website/blob/main/assets/favicon.ico" type="image/x-icon">
|
||||
<script src="https://kit.fontawesome.com/728e740903.js" crossorigin="anonymous"></script>
|
||||
<style>
|
||||
html { width:100%; height:100%; margin:0; padding:0; }
|
||||
|
||||
body {
|
||||
/* background-color: rgb(4, 4, 85); */
|
||||
background-color: rgb(38, 39, 49);
|
||||
width:100%; height:100%; margin:0; padding:0;
|
||||
color: white;
|
||||
}
|
||||
.navbar {
|
||||
background-color: rgb(69, 11, 102);
|
||||
height: 50px;
|
||||
border-width: 1px;
|
||||
border-style: double;
|
||||
}
|
||||
|
||||
#right {
|
||||
float: right;
|
||||
margin-right: 50px;
|
||||
}
|
||||
|
||||
.logoutbtn {
|
||||
margin-top: 14px;
|
||||
scale: 1.7;
|
||||
}
|
||||
|
||||
.logoutbtn:hover {
|
||||
cursor: pointer;
|
||||
color: red;
|
||||
}
|
||||
|
||||
|
||||
h1 {
|
||||
color: rgb(0, 74, 235);
|
||||
outline-style: dotted;
|
||||
text-align: center;
|
||||
margin-right: 1%;
|
||||
margin-left: 1%;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: rgb(255, 255, 255);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
p {
|
||||
color: white;
|
||||
margin-left: 1%;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-left: 1%;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<script>
|
||||
window.onload = () => {
|
||||
if (!window.localStorage.getItem('serverInfo')) {
|
||||
document.getElementById('guildslink').href = '';
|
||||
document.getElementById('guildslink').style = 'cursor: no-drop;';
|
||||
}
|
||||
}
|
||||
function logout() {
|
||||
window.localStorage.clear();
|
||||
window.location.href = 'index.html';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar">
|
||||
<span style="padding-left: 50px;"></span>
|
||||
<a href="index.html" style="color: white"><i class="fa-solid fa-house-chimney", alt="Home" style="scale: 2; margin-top: 20px;"></i></a>
|
||||
|
||||
<span style="padding-left:50px;">
|
||||
<a href="myGuilds.html" id="guildslink"><i class="fa-solid fa-server" alt="Servers" style="scale: 2; color: rgb(11, 189, 189);"></i></a>
|
||||
</span>
|
||||
|
||||
<span style="padding-left:50px;"></span>
|
||||
<a href="https://github.com/ION606/selmerBot/wiki" target="_blank"><i class="fa-solid fa-book" style="scale: 2; color: white;" alt="WIKI"></i></a>
|
||||
|
||||
<span style="padding-left:50px;"></span>
|
||||
<a href="premium.html"><i class="fa-solid fa-crown" style="scale: 2; color: gold;" alt="PREMIUM"></i></a>
|
||||
|
||||
<!-- <button>Home</button> -->
|
||||
<span id="right">
|
||||
<button onclick="logout()" class="logoutbtn"><i class="fa-solid fa-arrow-right-from-bracket" alt="Log Out"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Main Page -->
|
||||
<h1>SELMER BOT PREMIUM</h1>
|
||||
|
||||
<h2>
|
||||
<u>Experience All Selmer Bot has to offer!</u>
|
||||
</h2>
|
||||
|
||||
<h2 style="font-size: 50px; margin: 20px; text-align: left; color: gold;">AI</h2>
|
||||
<h3>Chat with Selmer Bot!</h3>
|
||||
<img src = ''>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user