fix url bugs and improve account switcher
This commit is contained in:
parent
0fe2966ad1
commit
5148e1b77b
19 changed files with 186 additions and 175 deletions
|
@ -369,7 +369,7 @@ class Channel{
|
|||
if(!this.hasunreads){
|
||||
return;
|
||||
}
|
||||
fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages/"+this.lastmessageid+"/ack",{
|
||||
fetch(this.info.api+"/channels/"+this.snowflake+"/messages/"+this.lastmessageid+"/ack",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({})
|
||||
|
@ -437,7 +437,7 @@ class Channel{
|
|||
return div;
|
||||
}
|
||||
createChannel(name:string,type:number){
|
||||
fetch(this.info.api.toString()+"/guilds/"+this.guild.id+"/channels",{
|
||||
fetch(this.info.api+"/guilds/"+this.guild.id+"/channels",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -461,7 +461,7 @@ class Channel{
|
|||
["mdbox","Channel topic:",this.topic,function(){topic=this.value}],
|
||||
["checkbox","NSFW Channel",this.nsfw,function(){nsfw=this.checked}],
|
||||
["button","","submit",()=>{
|
||||
fetch(this.info.api.toString()+"/channels/"+thisid,{
|
||||
fetch(this.info.api+"/channels/"+thisid,{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -485,7 +485,7 @@ class Channel{
|
|||
console.log(full)
|
||||
}
|
||||
deleteChannel(){
|
||||
fetch(this.info.api.toString()+"/channels/"+this.snowflake,{
|
||||
fetch(this.info.api+"/channels/"+this.snowflake,{
|
||||
method:"DELETE",
|
||||
headers:this.headers
|
||||
})
|
||||
|
@ -527,7 +527,7 @@ class Channel{
|
|||
if(snowflake.getObject()){
|
||||
return snowflake.getObject();
|
||||
}else{
|
||||
const gety=await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages?limit=1&around="+id,{headers:this.headers})
|
||||
const gety=await fetch(this.info.api+"/channels/"+this.snowflake+"/messages?limit=1&around="+id,{headers:this.headers})
|
||||
const json=await gety.json();
|
||||
return new Message(json[0],this);
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ class Channel{
|
|||
lastmessage:Message;
|
||||
async putmessages(){
|
||||
if(this.allthewayup){return};
|
||||
const j=await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages?limit=100",{
|
||||
const j=await fetch(this.info.api+"/channels/"+this.snowflake+"/messages?limit=100",{
|
||||
headers: this.headers,
|
||||
});
|
||||
|
||||
|
@ -597,7 +597,7 @@ class Channel{
|
|||
if(id===this.lastmessage.id){
|
||||
return;
|
||||
}
|
||||
await fetch(this.info.api.toString()+"/channels/"+this.id+"/messages?limit=100&after="+id,{
|
||||
await fetch(this.info.api+"/channels/"+this.id+"/messages?limit=100&after="+id,{
|
||||
headers:this.headers
|
||||
}).then((j)=>{return j.json()}).then(response=>{
|
||||
let previd:SnowFlake<Message>=SnowFlake.getSnowFlakeFromID(id,Message);
|
||||
|
@ -628,7 +628,7 @@ class Channel{
|
|||
return;
|
||||
}
|
||||
|
||||
await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages?before="+id+"&limit=100",{
|
||||
await fetch(this.info.api+"/channels/"+this.snowflake+"/messages?before="+id+"&limit=100",{
|
||||
headers:this.headers
|
||||
}).then((j)=>{return j.json()}).then((response:messagejson[])=>{
|
||||
if(response.length<100){
|
||||
|
@ -727,7 +727,7 @@ class Channel{
|
|||
return;
|
||||
}
|
||||
this.typing=new Date().getTime()+6000;
|
||||
fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/typing",{
|
||||
fetch(this.info.api+"/channels/"+this.snowflake+"/typing",{
|
||||
method:"POST",
|
||||
headers:this.headers
|
||||
})
|
||||
|
@ -767,7 +767,7 @@ class Channel{
|
|||
body.message_reference=replyjson;
|
||||
}
|
||||
console.log(body)
|
||||
return await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages",{
|
||||
return await fetch(this.info.api+"/channels/"+this.snowflake+"/messages",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify(body)
|
||||
|
@ -787,7 +787,7 @@ class Channel{
|
|||
console.log(attachments[i])
|
||||
formData.append("files["+i+"]",attachments[i]);
|
||||
}
|
||||
return await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages", {
|
||||
return await fetch(this.info.api+"/channels/"+this.snowflake+"/messages", {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
headers:{"Authorization":this.headers.Authorization}
|
||||
|
@ -868,7 +868,7 @@ class Channel{
|
|||
}
|
||||
}
|
||||
async addRoleToPerms(role:Role){
|
||||
await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/permissions/"+role.snowflake,{
|
||||
await fetch(this.info.api+"/channels/"+this.snowflake+"/permissions/"+role.snowflake,{
|
||||
method:"PUT",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -886,7 +886,7 @@ class Channel{
|
|||
const permission=this.permission_overwrites.get(id);
|
||||
permission.allow=perms.allow;
|
||||
permission.deny=perms.deny;
|
||||
await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/permissions/"+id,{
|
||||
await fetch(this.info.api+"/channels/"+this.snowflake+"/permissions/"+id,{
|
||||
method:"PUT",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
|
|
@ -128,7 +128,7 @@ class Guild{
|
|||
noti
|
||||
],
|
||||
["button","","submit",_=>{
|
||||
fetch(this.info.api.toString()+"/v9/users/@me/guilds/settings",{
|
||||
fetch(this.info.api+"/v9/users/@me/guilds/settings",{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -173,7 +173,7 @@ class Guild{
|
|||
full.show();
|
||||
}
|
||||
async leave(){
|
||||
return fetch(this.info.api.toString()+"/users/@me/guilds/"+this.snowflake,{
|
||||
return fetch(this.info.api+"/users/@me/guilds/"+this.snowflake,{
|
||||
method:"DELETE",
|
||||
headers:this.headers
|
||||
})
|
||||
|
@ -221,14 +221,14 @@ class Guild{
|
|||
if(serverbug){
|
||||
for(const thing of build){
|
||||
console.log(build,thing)
|
||||
fetch(this.info.api.toString()+"/v9/guilds/"+this.snowflake+"/channels",{
|
||||
fetch(this.info.api+"/v9/guilds/"+this.snowflake+"/channels",{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify([thing])
|
||||
});
|
||||
}
|
||||
}else{
|
||||
fetch(this.info.api.toString()+"/v9/guilds/"+this.snowflake+"/channels",{
|
||||
fetch(this.info.api+"/v9/guilds/"+this.snowflake+"/channels",{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify(build)
|
||||
|
@ -256,7 +256,7 @@ class Guild{
|
|||
if(this.properties.icon!=null){
|
||||
const img=document.createElement("img");
|
||||
img.classList.add("pfp","servericon");
|
||||
img.src=this.info.cdn.toString()+"/icons/"+this.properties.id+"/"+this.properties.icon+".png";
|
||||
img.src=this.info.cdn+"/icons/"+this.properties.id+"/"+this.properties.icon+".png";
|
||||
divy.appendChild(img)
|
||||
img.onclick=()=>{
|
||||
console.log(this.loadGuild)
|
||||
|
@ -323,7 +323,7 @@ class Guild{
|
|||
full.show();
|
||||
}
|
||||
async delete(){
|
||||
return fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/delete",{
|
||||
return fetch(this.info.api+"/guilds/"+this.snowflake+"/delete",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
})
|
||||
|
@ -372,7 +372,7 @@ class Guild{
|
|||
}
|
||||
}
|
||||
this.unreads();
|
||||
fetch(this.info.api.toString()+"/v9/read-states/ack-bulk",{
|
||||
fetch(this.info.api+"/v9/read-states/ack-bulk",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify(build)
|
||||
|
@ -499,14 +499,14 @@ class Guild{
|
|||
this.printServers();
|
||||
}
|
||||
createChannel(name:string,type:number){
|
||||
fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/channels",{
|
||||
fetch(this.info.api+"/guilds/"+this.snowflake+"/channels",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({name: name, type: type})
|
||||
})
|
||||
}
|
||||
async createRole(name:string){
|
||||
const fetched=await fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"roles",{
|
||||
const fetched=await fetch(this.info.api+"/guilds/"+this.snowflake+"roles",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -526,7 +526,7 @@ class Guild{
|
|||
role.permissions.allow=perms.allow;
|
||||
role.permissions.deny=perms.deny;
|
||||
|
||||
await fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/roles/"+this.snowflake,{
|
||||
await fetch(this.info.api+"/guilds/"+this.snowflake+"/roles/"+this.snowflake,{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
|
|
@ -31,40 +31,30 @@ thisuser.initwebsocket().then(_=>{
|
|||
const userinfo=document.getElementById("userinfo");
|
||||
const userdock=document.getElementById("userdock");
|
||||
userinfo.addEventListener("click",function(event){
|
||||
const table=document.createElement("table");
|
||||
const table=document.createElement("div");
|
||||
for(const thing of Object.values(users.users)){
|
||||
const specialuser=thing as Specialuser;
|
||||
console.log(specialuser.pfpsrc)
|
||||
const tr=document.createElement("tr");
|
||||
const td=document.createElement("td");
|
||||
|
||||
const userinfo=document.createElement("table");
|
||||
userinfo.classList.add("switchtable");
|
||||
const row=document.createElement("tr");
|
||||
userinfo.append(row)
|
||||
const pfpcell=document.createElement("td");
|
||||
row.append(pfpcell);
|
||||
const userinfo=document.createElement("div");
|
||||
userinfo.classList.add("flexltr","switchtable");
|
||||
const pfp=document.createElement("img");
|
||||
pfpcell.append(pfp);
|
||||
userinfo.append(pfp);
|
||||
|
||||
const usertd=document.createElement("td")
|
||||
row.append(usertd);
|
||||
const user=document.createElement("div");
|
||||
usertd.append(user);
|
||||
userinfo.append(user);
|
||||
user.append(specialuser.username);
|
||||
user.append(document.createElement("br"));
|
||||
const span=document.createElement("span");
|
||||
span.textContent=specialuser.serverurls.wellknown.hostname;
|
||||
span.textContent=specialuser.serverurls.wellknown.replace("https://","").replace("http://","");
|
||||
user.append(span);
|
||||
user.classList.add("userinfo")
|
||||
span.classList.add("serverURL")
|
||||
|
||||
pfp.src=specialuser.pfpsrc;
|
||||
pfp.classList.add("pfp");
|
||||
td.append(userinfo)
|
||||
|
||||
tr.append(td);
|
||||
table.append(tr);
|
||||
tr.addEventListener("click",_=>{
|
||||
table.append(userinfo);
|
||||
userinfo.addEventListener("click",_=>{
|
||||
thisuser.unload();
|
||||
document.getElementById("loading").classList.remove("doneloading");
|
||||
document.getElementById("loading").classList.add("loading");
|
||||
|
@ -82,14 +72,13 @@ thisuser.initwebsocket().then(_=>{
|
|||
})
|
||||
}
|
||||
{
|
||||
const tr=document.createElement("tr");
|
||||
const td=document.createElement("td");
|
||||
tr.append(td);
|
||||
const td=document.createElement("div");
|
||||
td.classList.add("switchtable")
|
||||
td.append("Switch accounts ⇌");
|
||||
td.addEventListener("click",_=>{
|
||||
window.location.href="/login.html";
|
||||
})
|
||||
table.append(tr);
|
||||
table.append(td);
|
||||
}
|
||||
table.classList.add("accountSwitcher");
|
||||
if(Contextmenu.currentmenu!=""){
|
||||
|
@ -97,7 +86,7 @@ thisuser.initwebsocket().then(_=>{
|
|||
}
|
||||
Contextmenu.currentmenu=table;
|
||||
console.log(table);
|
||||
userdock.before(table);
|
||||
document.body.append(table);
|
||||
event.stopImmediatePropagation();
|
||||
})
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ class Localuser{
|
|||
lastSequence:number|null=null;
|
||||
token:string;
|
||||
userinfo:Specialuser;
|
||||
serverurls;
|
||||
serverurls:Specialuser["serverurls"];
|
||||
initialized:boolean;
|
||||
info;
|
||||
info:Specialuser["serverurls"];
|
||||
headers:{"Content-type":string,Authorization:string};
|
||||
usersettings:Settings;
|
||||
userConnections:Fullscreen;
|
||||
|
@ -487,7 +487,7 @@ class Localuser{
|
|||
}else{
|
||||
parsed=inviteurl;
|
||||
}
|
||||
fetch(this.info.api.toString()+"/v9/invites/"+parsed,{
|
||||
fetch(this.info.api+"/v9/invites/"+parsed,{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
}).then(r=>r.json()).then(_=>{
|
||||
|
@ -512,7 +512,7 @@ class Localuser{
|
|||
const full=new Fullscreen(["html", content]);
|
||||
full.show();
|
||||
|
||||
const res=await fetch(this.info.api.toString()+"/v9/discoverable-guilds?limit=50", {
|
||||
const res=await fetch(this.info.api+"/v9/discoverable-guilds?limit=50", {
|
||||
headers: this.headers
|
||||
});
|
||||
const json=await res.json();
|
||||
|
@ -533,7 +533,7 @@ class Localuser{
|
|||
const banner=document.createElement("img");
|
||||
banner.classList.add("banner");
|
||||
banner.crossOrigin="anonymous";
|
||||
banner.src=this.info.cdn.toString()+"icons/"+guild.id+"/"+guild.banner+".png?size=256";
|
||||
banner.src=this.info.cdn+"icons/"+guild.id+"/"+guild.banner+".png?size=256";
|
||||
banner.alt="";
|
||||
content.appendChild(banner);
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ class Localuser{
|
|||
const img=document.createElement("img");
|
||||
img.classList.add("icon");
|
||||
img.crossOrigin="anonymous";
|
||||
img.src=this.info.cdn.toString()+(guild.icon ? ("/icons/"+guild.id+"/"+guild.icon+".png?size=48") : "/embed/avatars/3.png");
|
||||
img.src=this.info.cdn+(guild.icon ? ("/icons/"+guild.id+"/"+guild.icon+".png?size=48") : "/embed/avatars/3.png");
|
||||
img.alt="";
|
||||
nameContainer.appendChild(img);
|
||||
|
||||
|
@ -556,7 +556,7 @@ class Localuser{
|
|||
content.appendChild(desc);
|
||||
|
||||
content.addEventListener("click", async ()=>{
|
||||
const joinRes=await fetch(this.info.api.toString()+"/v9/guilds/"+guild.id+"/members/@me", {
|
||||
const joinRes=await fetch(this.info.api+"/v9/guilds/"+guild.id+"/members/@me", {
|
||||
method: "PUT",
|
||||
headers: this.headers
|
||||
});
|
||||
|
@ -611,7 +611,7 @@ class Localuser{
|
|||
var reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = ()=>{
|
||||
fetch(this.info.api.toString()+"/users/@me",{
|
||||
fetch(this.info.api+"/users/@me",{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -622,7 +622,7 @@ class Localuser{
|
|||
|
||||
}
|
||||
updatepronouns(pronouns:string):void{
|
||||
fetch(this.info.api.toString()+"/users/@me/profile",{
|
||||
fetch(this.info.api+"/users/@me/profile",{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -631,7 +631,7 @@ class Localuser{
|
|||
});
|
||||
}
|
||||
updatebio(bio:string):void{
|
||||
fetch(this.info.api.toString()+"/v9/users/@me/profile",{
|
||||
fetch(this.info.api+"/v9/users/@me/profile",{
|
||||
method:"PATCH",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -755,7 +755,7 @@ class Localuser{
|
|||
const security=settings.addButton("Account Security");
|
||||
if(this.mfa_enabled){
|
||||
security.addTextInput("Disable 2FA, totp code:",_=>{
|
||||
fetch(this.info.api.toString()+"/users/@me/mfa/totp/disable",{
|
||||
fetch(this.info.api+"/users/@me/mfa/totp/disable",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -786,7 +786,7 @@ class Localuser{
|
|||
["textbox","Account password:","",function(){password=this.value}],
|
||||
["textbox","Code:","",function(){code=this.value}],
|
||||
["button","","Submit",()=>{
|
||||
fetch(this.info.api.toString()+"/users/@me/mfa/totp/enable/",{
|
||||
fetch(this.info.api+"/users/@me/mfa/totp/enable/",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
body:JSON.stringify({
|
||||
|
@ -826,7 +826,7 @@ class Localuser{
|
|||
], () => {}, async () => {
|
||||
connectionContainer.innerHTML="";
|
||||
|
||||
const res=await fetch(this.info.api.toString()+"/v9/connections", {
|
||||
const res=await fetch(this.info.api+"/v9/connections", {
|
||||
headers: this.headers
|
||||
});
|
||||
const json=await res.json();
|
||||
|
@ -839,7 +839,7 @@ class Localuser{
|
|||
|
||||
if (connection.enabled) {
|
||||
container.addEventListener("click", async () => {
|
||||
const connectionRes=await fetch(this.info.api.toString()+"/v9/connections/" + key + "/authorize", {
|
||||
const connectionRes=await fetch(this.info.api+"/v9/connections/" + key + "/authorize", {
|
||||
headers: this.headers
|
||||
});
|
||||
const connectionJSON=await connectionRes.json();
|
||||
|
@ -870,7 +870,7 @@ class Localuser{
|
|||
async () => {
|
||||
if (appName.trim().length == 0) return alert("Please enter a name for the application.");
|
||||
|
||||
const res=await fetch(this.info.api.toString()+"/v9/applications", {
|
||||
const res=await fetch(this.info.api+"/v9/applications", {
|
||||
method: "POST",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify({
|
||||
|
@ -889,7 +889,7 @@ class Localuser{
|
|||
], () => {}, async () => {
|
||||
appListContainer.innerHTML="";
|
||||
|
||||
const res=await fetch(this.info.api.toString()+"/v9/applications", {
|
||||
const res=await fetch(this.info.api+"/v9/applications", {
|
||||
headers: this.headers
|
||||
});
|
||||
const json=await res.json();
|
||||
|
@ -900,7 +900,7 @@ class Localuser{
|
|||
if (application.cover_image) {
|
||||
const cover=document.createElement("img");
|
||||
cover.crossOrigin="anonymous";
|
||||
cover.src=this.info.cdn.toString()+"/app-icons/" + application.id + "/" + application.cover_image + ".png?size=256";
|
||||
cover.src=this.info.cdn+"/app-icons/" + application.id + "/" + application.cover_image + ".png?size=256";
|
||||
cover.alt="";
|
||||
cover.loading="lazy";
|
||||
container.appendChild(cover);
|
||||
|
@ -920,7 +920,7 @@ class Localuser{
|
|||
)
|
||||
}
|
||||
async manageApplication(appId="") {
|
||||
const res=await fetch(this.info.api.toString()+"/v9/applications/" + appId, {
|
||||
const res=await fetch(this.info.api+"/v9/applications/" + appId, {
|
||||
headers: this.headers
|
||||
});
|
||||
const json=await res.json();
|
||||
|
@ -939,7 +939,7 @@ class Localuser{
|
|||
fields.description=event.target.value;
|
||||
}],
|
||||
["vdiv",
|
||||
json.icon ? ["img", this.info.cdn.toString()+"/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"],
|
||||
json.icon ? ["img", this.info.cdn+"/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"],
|
||||
["fileupload", "Application icon:", event => {
|
||||
const reader=new FileReader();
|
||||
reader.readAsDataURL(event.target.files[0]);
|
||||
|
@ -970,7 +970,7 @@ class Localuser{
|
|||
"",
|
||||
"Save changes",
|
||||
async () => {
|
||||
const updateRes=await fetch(this.info.api.toString()+"/v9/applications/" + appId, {
|
||||
const updateRes=await fetch(this.info.api+"/v9/applications/" + appId, {
|
||||
method: "PATCH",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify(fields)
|
||||
|
@ -989,7 +989,7 @@ class Localuser{
|
|||
if (!json.bot) {
|
||||
if (!confirm("Are you sure you want to add a bot to this application? There's no going back.")) return;
|
||||
|
||||
const updateRes=await fetch(this.info.api.toString()+"/v9/applications/" + appId + "/bot", {
|
||||
const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot", {
|
||||
method: "POST",
|
||||
headers: this.headers
|
||||
});
|
||||
|
@ -1007,7 +1007,7 @@ class Localuser{
|
|||
appDialog.show();
|
||||
}
|
||||
async manageBot(appId="") {
|
||||
const res=await fetch(this.info.api.toString()+"/v9/applications/" + appId, {
|
||||
const res=await fetch(this.info.api+"/v9/applications/" + appId, {
|
||||
headers: this.headers
|
||||
});
|
||||
const json=await res.json();
|
||||
|
@ -1015,7 +1015,7 @@ class Localuser{
|
|||
|
||||
const fields: any={
|
||||
username: json.bot.username,
|
||||
avatar: json.bot.avatar ? (this.info.cdn.toString()+"/app-icons/" + appId + "/" + json.bot.avatar + ".png?size=256") : ""
|
||||
avatar: json.bot.avatar ? (this.info.cdn+"/app-icons/" + appId + "/" + json.bot.avatar + ".png?size=256") : ""
|
||||
};
|
||||
const botDialog=new Fullscreen(
|
||||
["vdiv",
|
||||
|
@ -1042,7 +1042,7 @@ class Localuser{
|
|||
"",
|
||||
"Save changes",
|
||||
async () => {
|
||||
const updateRes=await fetch(this.info.api.toString()+"/v9/applications/" + appId + "/bot", {
|
||||
const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot", {
|
||||
method: "PATCH",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify(fields)
|
||||
|
@ -1060,7 +1060,7 @@ class Localuser{
|
|||
async () => {
|
||||
if (!confirm("Are you sure you want to reset the bot token? Your bot will stop working until you update it.")) return;
|
||||
|
||||
const updateRes=await fetch(this.info.api.toString()+"/v9/applications/" + appId + "/bot/reset", {
|
||||
const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot/reset", {
|
||||
method: "POST",
|
||||
headers: this.headers
|
||||
});
|
||||
|
|
|
@ -57,7 +57,7 @@ function setDefaults(){
|
|||
}
|
||||
setDefaults();
|
||||
class Specialuser{
|
||||
serverurls;
|
||||
serverurls:{api:string,cdn:string,gateway:string,wellknown:string,login:string};
|
||||
email:string;
|
||||
token:string;
|
||||
loggedin;
|
||||
|
@ -67,10 +67,13 @@ class Specialuser{
|
|||
console.error("specialuser can't construct from another specialuser");
|
||||
}
|
||||
this.serverurls=json.serverurls;
|
||||
this.serverurls.api=new URL(this.serverurls.api);
|
||||
this.serverurls.cdn=new URL(this.serverurls.cdn);
|
||||
this.serverurls.gateway=new URL(this.serverurls.gateway);
|
||||
this.serverurls.wellknown=new URL(this.serverurls.wellknown);
|
||||
let apistring=new URL(json.serverurls.api).toString();
|
||||
apistring=apistring.replace(/\/(v\d+\/?)?$/, "")+"/v9";
|
||||
this.serverurls.api=apistring;
|
||||
this.serverurls.cdn=new URL(json.serverurls.cdn).toString().replace(/\/$/,"");
|
||||
this.serverurls.gateway=new URL(json.serverurls.gateway).toString().replace(/\/$/,"");;
|
||||
this.serverurls.wellknown=new URL(json.serverurls.wellknown).toString().replace(/\/$/,"");;
|
||||
this.serverurls.login=new URL(json.serverurls.login).toString().replace(/\/$/,"");;
|
||||
this.email=json.email;
|
||||
this.token=json.token;
|
||||
this.loggedin=json.loggedin;
|
||||
|
|
|
@ -421,7 +421,7 @@ class MarkDown{
|
|||
emojiElem.classList.add("md-emoji");
|
||||
emojiElem.classList.add(isEmojiOnly ? "bigemoji" : "smallemoji");
|
||||
emojiElem.crossOrigin="anonymous";
|
||||
emojiElem.src=this.info.cdn.toString() + "emojis/" + parts[2] + "." + (parts[1] ? "gif" : "png") + "?size=32";
|
||||
emojiElem.src=this.info.cdn + "emojis/" + parts[2] + "." + (parts[1] ? "gif" : "png") + "?size=32";
|
||||
|
||||
emojiElem.alt=buildjoin;
|
||||
emojiElem.loading="lazy";
|
||||
|
|
|
@ -18,7 +18,7 @@ class Member{
|
|||
navigator.clipboard.writeText(this.id);
|
||||
});
|
||||
this.contextmenu.addbutton("Message user",function(){
|
||||
fetch(this.info.api.toString()+"/v9/users/@me/channels",
|
||||
fetch(this.info.api+"/v9/users/@me/channels",
|
||||
{method:"POST",
|
||||
body:JSON.stringify({"recipients":[this.id]}),
|
||||
headers: this.headers
|
||||
|
|
|
@ -86,7 +86,7 @@ class Message{
|
|||
break;
|
||||
}
|
||||
}
|
||||
fetch(this.info.api.toString()+ "/channels/"+this.channel.id+"/messages/"+this.id+"/reactions/"+encodeURIComponent(emoji)+"/@me",{
|
||||
fetch(this.info.api+ "/channels/"+this.channel.id+"/messages/"+this.id+"/reactions/"+encodeURIComponent(emoji)+"/@me",{
|
||||
method:remove?"DELETE":"PUT",
|
||||
headers:this.headers,
|
||||
})
|
||||
|
@ -186,14 +186,14 @@ class Message{
|
|||
return build;
|
||||
}
|
||||
async edit(content){
|
||||
return await fetch(this.info.api.toString()+"/channels/"+this.channel.snowflake+"/messages/"+this.id,{
|
||||
return await fetch(this.info.api+"/channels/"+this.channel.snowflake+"/messages/"+this.id,{
|
||||
method: "PATCH",
|
||||
headers: this.headers,
|
||||
body:JSON.stringify({content:content})
|
||||
});
|
||||
}
|
||||
delete(){
|
||||
fetch(`${this.info.api.toString()}/channels/${this.channel.snowflake}/messages/${this.id}`,{
|
||||
fetch(`${this.info.api}/channels/${this.channel.snowflake}/messages/${this.id}`,{
|
||||
headers:this.headers,
|
||||
method:"DELETE",
|
||||
})
|
||||
|
|
|
@ -1044,20 +1044,28 @@ span {
|
|||
.accountSwitcher{
|
||||
background:var(--profile-bg);
|
||||
cursor:pointer;
|
||||
box-shadow: .00in -.5in 1in color-mix(in srgb, var(--shadow) 42%, transparent);
|
||||
border-radius: .05in .05in .0in.0in;
|
||||
flex-grow: 0;
|
||||
align-self: center;
|
||||
flex-shrink: 1;
|
||||
box-shadow: .00in -.5in 2in color-mix(in srgb, var(--shadow) 42%, transparent);
|
||||
border-radius: .1in;
|
||||
min-width: 0px;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
padding-left:.025in;
|
||||
width: 80vw;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: .1in;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
max-height: 80vh;
|
||||
overflow: auto;
|
||||
border:solid var(--black) .035in;
|
||||
}
|
||||
.accountSwitcher tr{
|
||||
.switchtable{
|
||||
transition: background .3s;
|
||||
background:var(--profile-bg);
|
||||
}
|
||||
.switchtable:hover{
|
||||
background:var(--profile-info-bg);
|
||||
}
|
||||
.accountSwitcher tr:hover{
|
||||
background:var(--profile-info-bg);
|
||||
}
|
||||
|
@ -1636,3 +1644,18 @@ form div{
|
|||
.dontshrink{
|
||||
flex-shrink:0;
|
||||
}
|
||||
.switchtable{
|
||||
flex-grow:1;
|
||||
flex-shrink: 0;
|
||||
padding: .05in;
|
||||
border-radius: .1in;
|
||||
margin-bottom: .05in;
|
||||
background: var(--message-bg-hover);
|
||||
border: solid var(--black) .03in;
|
||||
box-shadow: .01in .01in .05in var(--black);
|
||||
align-items: center;
|
||||
}
|
||||
.userinfo{
|
||||
margin-left:.1in;
|
||||
height:fit-content;
|
||||
}
|
|
@ -52,7 +52,7 @@ class User{
|
|||
navigator.clipboard.writeText(this.id.id);
|
||||
});
|
||||
this.contextmenu.addbutton("Message user",function(){
|
||||
fetch(this.info.api.toString()+"/v9/users/@me/channels",
|
||||
fetch(this.info.api+"/v9/users/@me/channels",
|
||||
{method:"POST",
|
||||
body:JSON.stringify({"recipients":[this.id.id]}),
|
||||
headers: this.localuser.headers
|
||||
|
@ -144,9 +144,9 @@ class User{
|
|||
return this.avatar;
|
||||
}
|
||||
if(this.avatar!=null){
|
||||
return this.info.cdn.toString()+"/avatars/"+this.id+"/"+this.avatar+".png";
|
||||
return this.info.cdn+"/avatars/"+this.id+"/"+this.avatar+".png";
|
||||
}else{
|
||||
return this.info.cdn.toString()+"/embed/avatars/3.png";
|
||||
return this.info.cdn+"/embed/avatars/3.png";
|
||||
}
|
||||
}
|
||||
createjankpromises(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue