fix: don't expect channel to exist

This commit is contained in:
Paul Makles
2023-04-20 13:38:09 +01:00
parent d5cf38973f
commit 97b74940d4
3 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -148,8 +148,8 @@ export class Channel {
*/
get recipient() {
return this.type === "DirectMessage"
? this.recipients.find(
(user) => user.id !== this.#collection.client.user!.id
? this.recipients?.find(
(user) => user?.id !== this.#collection.client.user!.id
)
: undefined;
}
+3 -3
View File
@@ -31,7 +31,7 @@ export class Message {
* Absolute pathname to this message in the client
*/
get path() {
return `${this.channel!.path}/${this.id}`;
return `${this.channel?.path}/${this.id}`;
}
/**
@@ -68,7 +68,7 @@ export class Message {
* Server this message was sent in
*/
get server() {
return this.channel!.server;
return this.channel?.server;
}
/**
@@ -76,7 +76,7 @@ export class Message {
*/
get member() {
return this.#collection.client.serverMembers.getByKey({
server: this.channel!.serverId,
server: this.channel?.serverId as string,
user: this.authorId!,
});
}
+2 -2
View File
@@ -2,7 +2,7 @@ export * from "./classes";
export * from "./lib/regex";
export * from "./collections";
export * as API from "revolt-api";
export type { Session } from "./Client";
export { Client, ClientOptions } from "./Client";
export { Client } from "./Client";
export type { Session, ClientOptions } from "./Client";
export { EventClient, ConnectionState } from "./events";
export { ServerFlags, UserBadges, UserFlags, BotFlags } from "./hydration";