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
|
@ -361,7 +361,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({})
|
||||
|
@ -429,7 +429,7 @@ class Channel {
|
|||
return div;
|
||||
}
|
||||
createChannel(name, type) {
|
||||
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({
|
||||
|
@ -452,7 +452,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({
|
||||
|
@ -475,7 +475,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
|
||||
});
|
||||
|
@ -518,7 +518,7 @@ class Channel {
|
|||
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);
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ class Channel {
|
|||
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,
|
||||
});
|
||||
const response = await j.json();
|
||||
|
@ -591,7 +591,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.getSnowFlakeFromID(id, Message);
|
||||
|
@ -622,7 +622,7 @@ class Channel {
|
|||
if (this.topid && id === this.topid.id) {
|
||||
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) => {
|
||||
if (response.length < 100) {
|
||||
|
@ -725,7 +725,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
|
||||
});
|
||||
|
@ -768,7 +768,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)
|
||||
|
@ -789,7 +789,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 }
|
||||
|
@ -877,7 +877,7 @@ class Channel {
|
|||
}
|
||||
}
|
||||
async addRoleToPerms(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({
|
||||
|
@ -895,7 +895,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({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue