Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:D3VSJ/BetterDiscordPanel.git
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjay Sunil authored and Sanjay Sunil committed Dec 26, 2020
2 parents 6d9d6f4 + e0b7305 commit fb2b590
Show file tree
Hide file tree
Showing 9 changed files with 840 additions and 547 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
./assets/js/panel.js
# Remove Debug logs
scripts/boot/debug.log
# Node Modules
node_modules
# Package
package-lock.json
34 changes: 33 additions & 1 deletion assets/css/bootstrap-dark.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -13159,4 +13159,36 @@ input:checked+.slider::before {
.chatHeader h1 {
font-size: 50px;
animation: fadeIn 1s infinite alternate;
}
}

table{
width:100%;
table-layout: fixed;
}
.tbl-header{
background-color: rgba(255,255,255,0.3);
}
.tbl-content{
height:300px;
overflow-x:auto;
margin-top: 0px;
border: 1px solid rgba(255,255,255,0.3);
}
th{
padding: 20px 15px;
text-align: left;
font-weight: 500;
font-size: 12px;
color: #fff;
text-transform: uppercase;
}
td{
padding: 15px;
text-align: left;
vertical-align:middle;
font-weight: 300;
font-size: 12px;
color: #fff;
border-bottom: solid 1px rgba(255,255,255,0.1);
}

33 changes: 32 additions & 1 deletion assets/css/bootstrap.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -13111,4 +13111,35 @@ input:checked+.slider::before {
.chatHeader h1 {
font-size: 50px;
animation: fadeIn 1s infinite alternate;
}
}

table{
width:100%;
table-layout: fixed;
}
.tbl-header{
background-color: rgba(255,255,255,0.3);
}
.tbl-content{
height:300px;
overflow-x:auto;
margin-top: 0px;
border: 1px solid rgba(255,255,255,0.3);
}
th{
padding: 20px 15px;
text-align: left;
font-weight: 500;
font-size: 12px;
color: #000;
text-transform: uppercase;
}
td{
padding: 15px;
text-align: left;
vertical-align:middle;
font-weight: 300;
font-size: 12px;
color: #000;
border-bottom: solid 1px rgba(255,255,255,0.1);
}
26 changes: 2 additions & 24 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,8 @@
}
}(jQuery);

const status = $("#status");

const hostname = location.hostname;
const pathname = window.location.pathname;

console.log(hostname)
console.log(pathname)

//if (hostname != "")
// console.log("WARNING: YOU ARE NOT ALLOWED TO DISTRIBUTE BETTERDISCORDPANEL ONTO A DOMAIN!")

var authorizedpath = pathname.startsWith("/");

if (authorizedpath = false) {
console.log("RESTRICTED");
$("#app").style.display("none");

} else if (hostname != "") {
console.log("RESTRICTED");
$("#app").style.display("none");

} else {
console.log("BetterDiscordPanel is now Authorized.");
}

//const verification_result = result.startsWith("file:///");
//console.log(verification_result);
console.log("Host: ",hostname)
console.log("File path: ",pathname)
16 changes: 3 additions & 13 deletions assets/js/main/isLoggedIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@
*/

let token;
const status = $("#status");

if (
!localStorage.getItem("token") ||
localStorage.getItem("token") === "" ||
localStorage.getItem("token") === null
) {
localStorage.setItem("isLoggedIn", "0");
window.location.replace('login.html')
}

status.html("Connecting to Bot Token ...")
status.html("Connecting to Discord Bot ...")

token = localStorage.getItem("token")

Expand All @@ -24,16 +16,14 @@ const client = new Discord.Client({
fetchAllMembers: false
});


client.login(token)
.then(() => {
status.html("Ready!");
setTimeout(function () {
$('.preloader').fadeOut(300, function () {});
}, 1500);
localStorage.setItem("isLoggedIn", "1");
})
.catch(() => {
.catch((err) => {
status.html("ERROR! Invalid Token!");
location.replace('login.html')
});
Expand Down
54 changes: 44 additions & 10 deletions assets/js/main/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
* @license GPL-3.0
*/

if (localStorage.getItem("isLoggedIn") == "1") {
window.location.replace('index.html')
}
else {
}

function login() {
let token;
token = document.getElementById("token").value;
/**
* Set token into localStorage.
*/
localStorage.setItem("token", token);

token = localStorage.getItem("token");

const client = new Discord.Client({
Expand All @@ -25,10 +21,9 @@ function login() {
client.login(token).then()
.then(() => {
console.log("Success!")
localStorage.setItem("isLoggedIn", "1");
window.location.replace('index.html')
})
.catch(() => {
.catch((err) => {
new Noty({
type: 'error',
theme: "nest",
Expand All @@ -40,6 +35,45 @@ function login() {
force: false,
maxVisible: 5,
}).show()
console.log(err)
localStorage.setItem("token", null);
});
}
}

function testLogin() {
/**
* This function will check if the user has already logged into their account.
* A redirection will be made back to the panel if they have already logged in.
*/

token = localStorage.getItem("token");

const client = new Discord.Client({
messageCacheMaxSize: 5,
fetchAllMembers: false
});
client.login(token).then()
.then(() => {
/**
* User is already logged in.
*/
console.log("You are already logged into an account.")
// localStorage.setItem("isLoggedIn", "1");
window.location.replace('index.html')
})
.catch(() => {
/**
* User has not logged into a bot.
*/
console.log("Currently not logged into a bot.")
localStorage.setItem("token", null);
});
}

/**
* Check localstorage and run test when necessary.
*/
$(document).ready(function () {
testLogin();
});

60 changes: 60 additions & 0 deletions assets/js/main/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @file settings.js
* @author Sanjay Sunil (a.k.a D3VSJ)
* @license GPL-3.0
*/

const authorizationUrl = 'https://discordapp.com/api/oauth2/authorize?client_id={clientId}&scope=bot&permissions={permissions}'
let permissionInteger = 0

function displayResults() {
let url = authorizationUrl
.replace('{clientId}', encodeURIComponent(`${client.user.id}`))
.replace('{permissions}', String(permissionInteger))
document.getElementById('result').innerHTML = url
document.getElementById('result').href = url
document.getElementById('permissionsInteger').innerHTML = permissionInteger
}

const update = function () {
let permissionInputs = document.getElementsByClassName('permission')
let adminBox = document.getElementById('administrator')

if (adminBox.checked === true) {
for (let i = 0; i < permissionInputs.length; i++) {
permissionInputs[i].setAttribute('disabled', 'disabled')
}

permissionInteger = adminBox.value
displayResults()
} else {
for (let i = 0; i < permissionInputs.length; i++) {
permissionInputs[i].removeAttribute('disabled')
}

let checkedInputs = []
for (let i = 0; i < permissionInputs.length; i++) {
if (permissionInputs[i].checked === true) {
checkedInputs.push(permissionInputs[i])
}
}

permissionInteger = 0
for (let i = 0; i < checkedInputs.length; i++) {
permissionInteger = permissionInteger | checkedInputs[i].value
}
displayResults()
}
}

function load() {
let inputs = document.getElementsByClassName('input')

for (let i = 0; i < inputs.length; i++) {
inputs[i].addEventListener('input', update, false)
}

displayResults()
}

document.addEventListener('DOMContentLoaded', load, false)
9 changes: 9 additions & 0 deletions assets/js/panel/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,20 @@ function generateInvite() {
function OpenlastMessages() {
$(".channelName").html("Last Messages")
$("#chat").css("display", "none")
$("#createPermissionsInvite").css("display", "none")
$("#lastMessages").css("display", "block")
}

function OpenChat() {
$(".channelName").html("Chat")
$("#chat").css("display", "block")
$("#createPermissionsInvite").css("display", "none")
$("#lastMessages").css("display", "none")
}

function OpenPermissionsInviteSettings() {
$(".channelName").html("Create Bot Invite")
$("#chat").css("display", "none")
$("#createPermissionsInvite").css("display", "block")
$("#lastMessages").css("display", "none")
}
Loading

0 comments on commit fb2b590

Please sign in to comment.