feat: add lastMessage and displayName to Channel

This commit is contained in:
Paul Makles
2023-04-09 15:04:26 +01:00
parent dc35456e6f
commit 17ee78f00e
+22
View File
@@ -32,6 +32,10 @@ export class Channel {
this.id = id;
}
toString() {
return `<#${this.id}>`;
}
/**
* Time when this server was created
*/
@@ -71,6 +75,17 @@ export class Channel {
return this.#collection.getUnderlyingObject(this.id).name;
}
/**
* Display name
*/
get displayName() {
return this.type === "SavedMessages"
? this.user?.username
: this.type === "DirectMessage"
? this.recipient?.username
: this.name;
}
/**
* Channel description
*/
@@ -218,6 +233,13 @@ export class Channel {
return this.#collection.getUnderlyingObject(this.id).lastMessageId;
}
/**
* Last message sent in this channel
*/
get lastMessage() {
return this.#collection.client.messages.get(this.lastMessageId!);
}
/**
* Time when the last message was sent
*/