Lightcord Servers first commit

This commit is contained in:
Jean Ouina 2020-05-27 20:19:13 +02:00
parent 42b08bc8c2
commit 22ac7a8090
3 changed files with 46 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@ -58,6 +58,7 @@ export const settings = {
"Calling Ring Beat": {id: "lightcord-2", info: "Enable Discord's special calling beat.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
"Developer Options": {id: "lightcord-1", info: "Enable Discord's Internal Developer Options. This allow the \"Experiments\" tab and the \"Developer Options\" tab. (must close and reopen settings)", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
"Ad Block": {id: "lightcord-4", info: "Block any BOT that dm you with an invite link. Even in an embed.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
"Enable Lightcord Servers": {id: "lightcord-5", info: "Disabling it erase any informations about you in our servers. But you won't see anything like custom badges.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
/** Lightcord Window */
"Always-on-Top": {id: "lightcord-3", info: "Enable window's Always-on-Top mode, where Lightcord stays on top of other applications.", implemented: true, hidden: false, cat: "lightcord", category: "Window"},
@ -103,7 +104,8 @@ export const defaultCookie = {
"lightcord-2": true,
"lightcord-presence-1": false,
"lightcord-3": false,
"lightcord-4": false
"lightcord-4": false,
"lightcord-5": true
};

View File

@ -27,6 +27,24 @@ export default new class DistantServer {
return this._cache = Object.assign(this._cache, data)
}
async delete(){
BdApi.showToast("Deleting all infos about you on Lightcord Servers...", {type: "warn"})
return handleRequest(Routes.delete, "delete")
.then(async res => {
if(res.status !== 200){
BdApi.showToast("An error occured, couldn't delete informations. See console for more infos", {type: "error"})
throw new Error(`Couldn't delete all informations: ${(res.status+" "+res.statusText+" "+await res.text())}`)
}
console.info(`Succesfully deleted informations.`)
BdApi.showToast("Succesfully deleted informations", {type: "success"})
window.Lightcord.Api.Authorization = null
return res.json()
}).catch((err) => {
BdApi.showToast("An error occured, couldn't delete informations. See console for more infos", {type: "error"})
throw new Error(`Couldn't delete all informations: ${err.stack}`)
})
}
/**
* Get custom badges from the user ID.
* @param {string} user The user ID
@ -77,7 +95,8 @@ const handleRequest = function(route, method){
return fetch(`${Constants.SERVER_URL}/api/v1${route}`, {
method,
headers: {
"CLIENT": "Lightcord"
"CLIENT": "Lightcord",
"Authorization": window.Lightcord.Api.Authorization || "None::Anonymous"
}
})
}
@ -86,11 +105,21 @@ export const Constants = {
SERVER_URL: "http://127.0.0.1",
badges: [
{
name: "Bug Hunter",
name: "Lightcord User",
id: "01cfa7b0-7cdb-4b0e-8258-9c6a78235c93",
defaultUsers: [
"696481194443014174"
],
scopes: [
"user"
],
component: BugHunterBadge,
href: "https://github.com/lightcord/lightcord/wiki/badges/bug_hunter"
}, {
name: "Lightcord Bug Hunter",
id: "f04698f5-816b-41e3-bd01-92291193d7a5",
defaultUsers: [
"696481194443014174",
"585858920149549067"
"696481194443014174"
],
scopes: [],
component: BugHunterBadge,
@ -100,7 +129,6 @@ export const Constants = {
}
export const Routes = {
badges(user){
return `/${user}/badges`
}
badges: user => `/${user}/badges`,
delete: `/delete`
}