remove snowflake instances
This commit is contained in:
@@ -6,7 +6,7 @@ import { Embed } from "./embed.js";
|
||||
import { File } from "./file.js";
|
||||
import { SnowFlake } from "./snowflake.js";
|
||||
import { Emoji } from "./emoji.js";
|
||||
class Message {
|
||||
class Message extends SnowFlake {
|
||||
static contextmenu = new Contextmenu("message menu");
|
||||
owner;
|
||||
headers;
|
||||
@@ -15,7 +15,6 @@ class Message {
|
||||
mentions;
|
||||
mention_roles;
|
||||
attachments; //probably should be its own class tbh, should be Attachments[]
|
||||
snowflake;
|
||||
message_reference;
|
||||
type;
|
||||
timestamp;
|
||||
@@ -38,9 +37,6 @@ class Message {
|
||||
div;
|
||||
member;
|
||||
reactions;
|
||||
get id() {
|
||||
return this.snowflake.id;
|
||||
}
|
||||
static setup() {
|
||||
this.del = new Promise(_ => {
|
||||
this.resolve = _;
|
||||
@@ -77,6 +73,7 @@ class Message {
|
||||
});
|
||||
}
|
||||
constructor(messagejson, owner) {
|
||||
super(messagejson.id);
|
||||
this.owner = owner;
|
||||
this.headers = this.owner.headers;
|
||||
this.giveData(messagejson);
|
||||
@@ -117,7 +114,6 @@ class Message {
|
||||
continue;
|
||||
}
|
||||
else if (thing === "id") {
|
||||
this.snowflake = new SnowFlake(messagejson.id);
|
||||
continue;
|
||||
}
|
||||
else if (thing === "member") {
|
||||
@@ -160,7 +156,7 @@ class Message {
|
||||
func();
|
||||
}
|
||||
canDelete() {
|
||||
return this.channel.hasPermission("MANAGE_MESSAGES") || this.author.snowflake === this.localuser.user.snowflake;
|
||||
return this.channel.hasPermission("MANAGE_MESSAGES") || this.author === this.localuser.user;
|
||||
}
|
||||
get channel() {
|
||||
return this.owner;
|
||||
@@ -208,14 +204,14 @@ class Message {
|
||||
return build;
|
||||
}
|
||||
async edit(content) {
|
||||
return await fetch(this.info.api + "/channels/" + this.channel.snowflake + "/messages/" + this.id, {
|
||||
return await fetch(this.info.api + "/channels/" + this.channel.id + "/messages/" + this.id, {
|
||||
method: "PATCH",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify({ content })
|
||||
});
|
||||
}
|
||||
delete() {
|
||||
fetch(`${this.info.api}/channels/${this.channel.snowflake}/messages/${this.id}`, {
|
||||
fetch(`${this.info.api}/channels/${this.channel.id}/messages/${this.id}`, {
|
||||
headers: this.headers,
|
||||
method: "DELETE",
|
||||
});
|
||||
@@ -387,7 +383,7 @@ class Message {
|
||||
const newt = (new Date(this.timestamp).getTime()) / 1000;
|
||||
current = (newt - old) > 600;
|
||||
}
|
||||
const combine = (premessage?.author?.snowflake != this.author.snowflake) || (current) || this.message_reference;
|
||||
const combine = (premessage?.author != this.author) || (current) || this.message_reference;
|
||||
if (combine) {
|
||||
const pfp = this.author.buildpfp();
|
||||
this.author.bind(pfp, this.guild, false);
|
||||
@@ -574,7 +570,7 @@ class Message {
|
||||
}
|
||||
buildhtml(premessage) {
|
||||
if (this.div) {
|
||||
console.error(`HTML for ${this.snowflake} already exists, aborting`);
|
||||
console.error(`HTML for ${this.id} already exists, aborting`);
|
||||
return this.div;
|
||||
}
|
||||
try {
|
||||
|
Reference in New Issue
Block a user