fix replies

This commit is contained in:
MathMan05 2024-09-19 13:05:31 -05:00
parent 5ffdb05a8e
commit 4e0fa3fdbb
2 changed files with 10 additions and 8 deletions

View file

@ -781,19 +781,17 @@ class Channel extends SnowFlake{
} }
} }
async getmessage(id: string): Promise<Message>{ async getmessage(id: string): Promise<Message>{
console.log("getting:"+id)
const message = this.messages.get(id); const message = this.messages.get(id);
if(message){ if(message){
return message; return message;
}else{ }else{
const gety = await fetch( const gety = await fetch(
this.info.api + this.info.api + "/channels/" +this.id +"/messages?limit=1&around=" +id,
"/channels/" +
this.id +
"/messages?limit=1&around=" +
id,
{ headers: this.headers } { headers: this.headers }
); );
const json = await gety.json(); const json = await gety.json();
console.log(json);
return new Message(json[0], this); return new Message(json[0], this);
} }
} }

View file

@ -21,7 +21,11 @@ class Message extends SnowFlake{
mentions!: User[]; mentions!: User[];
mention_roles!: Role[]; mention_roles!: Role[];
attachments!: File[]; //probably should be its own class tbh, should be Attachments[] attachments!: File[]; //probably should be its own class tbh, should be Attachments[]
message_reference!: messagejson; message_reference!: {
guild_id: string,
channel_id: string,
message_id: string
};
type!: number; type!: number;
timestamp!: number; timestamp!: number;
content!: MarkDown; content!: MarkDown;
@ -417,7 +421,7 @@ class Message extends SnowFlake{
line.classList.add("startreply"); line.classList.add("startreply");
replyline.classList.add("replyflex"); replyline.classList.add("replyflex");
// TODO: Fix this // TODO: Fix this
this.channel.getmessage(this.message_reference.id).then(message=>{ this.channel.getmessage(this.message_reference.message_id).then(message=>{
if(message.author.relationshipType === 2){ if(message.author.relationshipType === 2){
username.textContent = "Blocked user"; username.textContent = "Blocked user";
return; return;
@ -431,7 +435,7 @@ class Message extends SnowFlake{
}); });
reply.onclick = _=>{ reply.onclick = _=>{
// TODO: FIX this // TODO: FIX this
this.channel.infinite.focus(this.message_reference.id); this.channel.infinite.focus(this.message_reference.message_id);
}; };
div.appendChild(replyline); div.appendChild(replyline);
} }