Class MessageCollection

Collection of Messages

Hierarchy

Constructors

Properties

#objects: ReactiveMap<string, Message> = ...
#storage: ObjectStorage<HydratedMessage> = ...
client: Client
getUnderlyingObject: ((id: string) => HydratedMessage)

Type declaration

    • (id: string): HydratedMessage
    • Parameters

      • id: string

      Returns HydratedMessage

updateUnderlyingObject: SetStoreFunction<Record<string, HydratedMessage>>

Methods

  • Create a new instance of an object

    Parameters

    • id: string

      Id

    • type: "channel" | "user" | "server" | "bot" | "channelUnread" | "emoji" | "message" | "serverMember"

      Type

    • instance: Message

      Instance

    • context: unknown

      Context

    • Optional data: unknown

      Data

    Returns void

  • Get or create

    Parameters

    • id: string

      Id

    • data: {
          _id: string;
          attachments?: null | {
              _id: string;
              content_type: string;
              deleted?: null | boolean;
              filename: string;
              message_id?: null | string;
              metadata: {
                  type: "File";
              } | {
                  type: "Text";
              } | {
                  height: number;
                  type: "Image";
                  width: number;
              } | {
                  height: number;
                  type: "Video";
                  width: number;
              } | {
                  type: "Audio";
              };
              object_id?: null | string;
              reported?: null | boolean;
              server_id?: null | string;
              size: number;
              tag: string;
              user_id?: null | string;
          }[];
          author: string;
          channel: string;
          content?: null | string;
          edited?: null | string;
          embeds?: null | ({
              colour?: null | string;
              description?: null | string;
              icon_url?: null | string;
              image?: null | {
                  height: number;
                  size: "Large" | "Preview";
                  url: string;
                  width: number;
              };
              original_url?: null | string;
              site_name?: null | string;
              special?: null | {
                  type: "None";
              } | {
                  type: "GIF";
              } | {
                  id: string;
                  timestamp?: null | string;
                  type: "YouTube";
              } | {
                  content_type: "Channel";
                  id: string;
                  type: "Lightspeed";
              } | {
                  content_type: "Channel" | "Video" | "Clip";
                  id: string;
                  type: "Twitch";
              } | {
                  content_type: string;
                  id: string;
                  type: "Spotify";
              } | {
                  type: "Soundcloud";
              } | {
                  content_type: "Album" | "Track";
                  id: string;
                  type: "Bandcamp";
              } | {
                  id: string;
                  type: "Streamable";
              };
              title?: null | string;
              type: "Website";
              url?: null | string;
              video?: null | {
                  height: number;
                  url: string;
                  width: number;
              };
          } | {
              height: number;
              size: "Large" | "Preview";
              type: "Image";
              url: string;
              width: number;
          } | {
              height: number;
              type: "Video";
              url: string;
              width: number;
          } | {
              colour?: null | string;
              description?: null | string;
              icon_url?: null | string;
              media?: null | {
                  _id: string;
                  content_type: string;
                  deleted?: null | boolean;
                  filename: string;
                  message_id?: null | string;
                  metadata: {
                      type: "File";
                  } | {
                      type: "Text";
                  } | {
                      height: number;
                      type: "Image";
                      width: number;
                  } | {
                      height: number;
                      type: "Video";
                      width: number;
                  } | {
                      type: "Audio";
                  };
                  object_id?: null | string;
                  reported?: null | boolean;
                  server_id?: null | string;
                  size: number;
                  tag: string;
                  user_id?: null | string;
              };
              title?: null | string;
              type: "Text";
              url?: null | string;
          } | {
              type: "None";
          })[];
          interactions?: {
              reactions?: null | string[];
              restrict_reactions?: boolean;
          };
          masquerade?: null | {
              avatar?: null | string;
              colour?: null | string;
              name?: null | string;
          };
          mentions?: null | string[];
          nonce?: null | string;
          reactions?: {
              [key: string]: string[];
          };
          replies?: null | string[];
          system?: null | {
              content: string;
              type: "text";
          } | {
              by: string;
              id: string;
              type: "user_added";
          } | {
              by: string;
              id: string;
              type: "user_remove";
          } | {
              id: string;
              type: "user_joined";
          } | {
              id: string;
              type: "user_left";
          } | {
              id: string;
              type: "user_kicked";
          } | {
              id: string;
              type: "user_banned";
          } | {
              by: string;
              name: string;
              type: "channel_renamed";
          } | {
              by: string;
              type: "channel_description_changed";
          } | {
              by: string;
              type: "channel_icon_changed";
          } | {
              from: string;
              to: string;
              type: "channel_ownership_changed";
          };
      }

      Data

      • _id: string

        Description

        Unique Id

      • Optional attachments?: null | {
            _id: string;
            content_type: string;
            deleted?: null | boolean;
            filename: string;
            message_id?: null | string;
            metadata: {
                type: "File";
            } | {
                type: "Text";
            } | {
                height: number;
                type: "Image";
                width: number;
            } | {
                height: number;
                type: "Video";
                width: number;
            } | {
                type: "Audio";
            };
            object_id?: null | string;
            reported?: null | boolean;
            server_id?: null | string;
            size: number;
            tag: string;
            user_id?: null | string;
        }[]

        Description

        Array of attachments

      • author: string

        Description

        Id of the user that sent this message

      • channel: string

        Description

        Id of the channel this message was sent in

      • Optional content?: null | string

        Description

        Message content

      • Optional edited?: null | string

        Description

        Time at which this message was last edited

      • Optional embeds?: null | ({
            colour?: null | string;
            description?: null | string;
            icon_url?: null | string;
            image?: null | {
                height: number;
                size: "Large" | "Preview";
                url: string;
                width: number;
            };
            original_url?: null | string;
            site_name?: null | string;
            special?: null | {
                type: "None";
            } | {
                type: "GIF";
            } | {
                id: string;
                timestamp?: null | string;
                type: "YouTube";
            } | {
                content_type: "Channel";
                id: string;
                type: "Lightspeed";
            } | {
                content_type: "Channel" | "Video" | "Clip";
                id: string;
                type: "Twitch";
            } | {
                content_type: string;
                id: string;
                type: "Spotify";
            } | {
                type: "Soundcloud";
            } | {
                content_type: "Album" | "Track";
                id: string;
                type: "Bandcamp";
            } | {
                id: string;
                type: "Streamable";
            };
            title?: null | string;
            type: "Website";
            url?: null | string;
            video?: null | {
                height: number;
                url: string;
                width: number;
            };
        } | {
            height: number;
            size: "Large" | "Preview";
            type: "Image";
            url: string;
            width: number;
        } | {
            height: number;
            type: "Video";
            url: string;
            width: number;
        } | {
            colour?: null | string;
            description?: null | string;
            icon_url?: null | string;
            media?: null | {
                _id: string;
                content_type: string;
                deleted?: null | boolean;
                filename: string;
                message_id?: null | string;
                metadata: {
                    type: "File";
                } | {
                    type: "Text";
                } | {
                    height: number;
                    type: "Image";
                    width: number;
                } | {
                    height: number;
                    type: "Video";
                    width: number;
                } | {
                    type: "Audio";
                };
                object_id?: null | string;
                reported?: null | boolean;
                server_id?: null | string;
                size: number;
                tag: string;
                user_id?: null | string;
            };
            title?: null | string;
            type: "Text";
            url?: null | string;
        } | {
            type: "None";
        })[]

        Description

        Attached embeds to this message

      • Optional interactions?: {
            reactions?: null | string[];
            restrict_reactions?: boolean;
        }

        Description

        Information about how this message should be interacted with

        • Optional reactions?: null | string[]

          Description

          Reactions which should always appear and be distinct

        • Optional restrict_reactions?: boolean

          Description

          Whether reactions should be restricted to the given list

          Can only be set to true if reactions list is of at least length 1

      • Optional masquerade?: null | {
            avatar?: null | string;
            colour?: null | string;
            name?: null | string;
        }

        Description

        Name and / or avatar overrides for this message

      • Optional mentions?: null | string[]

        Description

        Array of user ids mentioned in this message

      • Optional nonce?: null | string

        Description

        Unique value generated by client sending this message

      • Optional reactions?: {
            [key: string]: string[];
        }

        Description

        Hashmap of emoji IDs to array of user IDs

        • [key: string]: string[]
      • Optional replies?: null | string[]

        Description

        Array of message ids this message is replying to

      • Optional system?: null | {
            content: string;
            type: "text";
        } | {
            by: string;
            id: string;
            type: "user_added";
        } | {
            by: string;
            id: string;
            type: "user_remove";
        } | {
            id: string;
            type: "user_joined";
        } | {
            id: string;
            type: "user_left";
        } | {
            id: string;
            type: "user_kicked";
        } | {
            id: string;
            type: "user_banned";
        } | {
            by: string;
            name: string;
            type: "channel_renamed";
        } | {
            by: string;
            type: "channel_description_changed";
        } | {
            by: string;
            type: "channel_icon_changed";
        } | {
            from: string;
            to: string;
            type: "channel_ownership_changed";
        }

        Description

        System message

    • isNew: boolean = false

      Whether this object is new

    Returns Message

  • Globally fetch messages

    Requires

    Admin

    Parameters

    • query: Object

      Message query

    Returns Promise<{
        _id: string;
        attachments?: null | {
            _id: string;
            content_type: string;
            deleted?: null | boolean;
            filename: string;
            message_id?: null | string;
            metadata: {
                type: "File";
            } | {
                type: "Text";
            } | {
                height: number;
                type: "Image";
                width: number;
            } | {
                height: number;
                type: "Video";
                width: number;
            } | {
                type: "Audio";
            };
            object_id?: null | string;
            reported?: null | boolean;
            server_id?: null | string;
            size: number;
            tag: string;
            user_id?: null | string;
        }[];
        author: string;
        channel: string;
        content?: null | string;
        edited?: null | string;
        embeds?: null | ({
            colour?: null | string;
            description?: null | string;
            icon_url?: null | string;
            image?: null | {
                height: number;
                size: "Large" | "Preview";
                url: string;
                width: number;
            };
            original_url?: null | string;
            site_name?: null | string;
            special?: null | {
                type: "None";
            } | {
                type: "GIF";
            } | {
                id: string;
                timestamp?: null | string;
                type: "YouTube";
            } | {
                content_type: "Channel";
                id: string;
                type: "Lightspeed";
            } | {
                content_type: "Channel" | "Video" | "Clip";
                id: string;
                type: "Twitch";
            } | {
                content_type: string;
                id: string;
                type: "Spotify";
            } | {
                type: "Soundcloud";
            } | {
                content_type: "Album" | "Track";
                id: string;
                type: "Bandcamp";
            } | {
                id: string;
                type: "Streamable";
            };
            title?: null | string;
            type: "Website";
            url?: null | string;
            video?: null | {
                height: number;
                url: string;
                width: number;
            };
        } | {
            height: number;
            size: "Large" | "Preview";
            type: "Image";
            url: string;
            width: number;
        } | {
            height: number;
            type: "Video";
            url: string;
            width: number;
        } | {
            colour?: null | string;
            description?: null | string;
            icon_url?: null | string;
            media?: null | {
                _id: string;
                content_type: string;
                deleted?: null | boolean;
                filename: string;
                message_id?: null | string;
                metadata: {
                    type: "File";
                } | {
                    type: "Text";
                } | {
                    height: number;
                    type: "Image";
                    width: number;
                } | {
                    height: number;
                    type: "Video";
                    width: number;
                } | {
                    type: "Audio";
                };
                object_id?: null | string;
                reported?: null | boolean;
                server_id?: null | string;
                size: number;
                tag: string;
                user_id?: null | string;
            };
            title?: null | string;
            type: "Text";
            url?: null | string;
        } | {
            type: "None";
        })[];
        interactions?: {
            reactions?: null | string[];
            restrict_reactions?: boolean;
        };
        masquerade?: null | {
            avatar?: null | string;
            colour?: null | string;
            name?: null | string;
        };
        mentions?: null | string[];
        nonce?: null | string;
        reactions?: {
            [key: string]: string[];
        };
        replies?: null | string[];
        system?: null | {
            content: string;
            type: "text";
        } | {
            by: string;
            id: string;
            type: "user_added";
        } | {
            by: string;
            id: string;
            type: "user_remove";
        } | {
            id: string;
            type: "user_joined";
        } | {
            id: string;
            type: "user_left";
        } | {
            id: string;
            type: "user_kicked";
        } | {
            id: string;
            type: "user_banned";
        } | {
            by: string;
            name: string;
            type: "channel_renamed";
        } | {
            by: string;
            type: "channel_description_changed";
        } | {
            by: string;
            type: "channel_icon_changed";
        } | {
            from: string;
            to: string;
            type: "channel_ownership_changed";
        };
    }[] | {
        members?: null | {
            _id: {
                server: string;
                user: string;
            };
            avatar?: null | {
                _id: string;
                content_type: string;
                deleted?: null | boolean;
                filename: string;
                message_id?: null | string;
                metadata: {
                    type: "File";
                } | {
                    type: "Text";
                } | {
                    height: number;
                    type: "Image";
                    width: number;
                } | {
                    height: number;
                    type: "Video";
                    width: number;
                } | {
                    type: "Audio";
                };
                object_id?: null | string;
                reported?: null | boolean;
                server_id?: null | string;
                size: number;
                tag: string;
                user_id?: null | string;
            };
            joined_at: string;
            nickname?: null | string;
            roles?: string[];
            timeout?: null | string;
        }[];
        messages: {
            _id: string;
            attachments?: null | {
                _id: string;
                content_type: string;
                deleted?: null | boolean;
                filename: string;
                message_id?: null | string;
                metadata: {
                    type: "File";
                } | {
                    type: "Text";
                } | {
                    height: number;
                    type: "Image";
                    width: number;
                } | {
                    height: number;
                    type: "Video";
                    width: number;
                } | {
                    type: "Audio";
                };
                object_id?: null | string;
                reported?: null | boolean;
                server_id?: null | string;
                size: number;
                tag: string;
                user_id?: null | string;
            }[];
            author: string;
            channel: string;
            content?: null | string;
            edited?: null | string;
            embeds?: null | ({
                colour?: null | string;
                description?: null | string;
                icon_url?: null | string;
                image?: null | {
                    height: number;
                    size: "Large" | "Preview";
                    url: string;
                    width: number;
                };
                original_url?: null | string;
                site_name?: null | string;
                special?: null | {
                    type: "None";
                } | {
                    type: "GIF";
                } | {
                    id: string;
                    timestamp?: null | string;
                    type: "YouTube";
                } | {
                    content_type: "Channel";
                    id: string;
                    type: "Lightspeed";
                } | {
                    content_type: "Channel" | "Video" | "Clip";
                    id: string;
                    type: "Twitch";
                } | {
                    content_type: string;
                    id: string;
                    type: "Spotify";
                } | {
                    type: "Soundcloud";
                } | {
                    content_type: "Album" | "Track";
                    id: string;
                    type: "Bandcamp";
                } | {
                    id: string;
                    type: "Streamable";
                };
                title?: null | string;
                type: "Website";
                url?: null | string;
                video?: null | {
                    height: number;
                    url: string;
                    width: number;
                };
            } | {
                height: number;
                size: "Large" | "Preview";
                type: "Image";
                url: string;
                width: number;
            } | {
                height: number;
                type: "Video";
                url: string;
                width: number;
            } | {
                colour?: null | string;
                description?: null | string;
                icon_url?: null | string;
                media?: null | {
                    _id: string;
                    content_type: string;
                    deleted?: null | boolean;
                    filename: string;
                    message_id?: null | string;
                    metadata: {
                        type: "File";
                    } | {
                        type: "Text";
                    } | {
                        height: number;
                        type: "Image";
                        width: number;
                    } | {
                        height: number;
                        type: "Video";
                        width: number;
                    } | {
                        type: "Audio";
                    };
                    object_id?: null | string;
                    reported?: null | boolean;
                    server_id?: null | string;
                    size: number;
                    tag: string;
                    user_id?: null | string;
                };
                title?: null | string;
                type: "Text";
                url?: null | string;
            } | {
                type: "None";
            })[];
            interactions?: {
                reactions?: null | string[];
                restrict_reactions?: boolean;
            };
            masquerade?: null | {
                avatar?: null | string;
                colour?: null | string;
                name?: null | string;
            };
            mentions?: null | string[];
            nonce?: null | string;
            reactions?: {
                [key: string]: string[];
            };
            replies?: null | string[];
            system?: null | {
                content: string;
                type: "text";
            } | {
                by: string;
                id: string;
                type: "user_added";
            } | {
                by: string;
                id: string;
                type: "user_remove";
            } | {
                id: string;
                type: "user_joined";
            } | {
                id: string;
                type: "user_left";
            } | {
                id: string;
                type: "user_kicked";
            } | {
                id: string;
                type: "user_banned";
            } | {
                by: string;
                name: string;
                type: "channel_renamed";
            } | {
                by: string;
                type: "channel_description_changed";
            } | {
                by: string;
                type: "channel_icon_changed";
            } | {
                from: string;
                to: string;
                type: "channel_ownership_changed";
            };
        }[];
        users: {
            _id: string;
            avatar?: null | {
                _id: string;
                content_type: string;
                deleted?: null | boolean;
                filename: string;
                message_id?: null | string;
                metadata: {
                    type: "File";
                } | {
                    type: "Text";
                } | {
                    height: number;
                    type: "Image";
                    width: number;
                } | {
                    height: number;
                    type: "Video";
                    width: number;
                } | {
                    type: "Audio";
                };
                object_id?: null | string;
                reported?: null | boolean;
                server_id?: null | string;
                size: number;
                tag: string;
                user_id?: null | string;
            };
            badges?: null | number;
            bot?: null | {
                owner: string;
            };
            flags?: null | number;
            online?: null | boolean;
            privileged?: boolean;
            profile?: null | {
                background?: null | {
                    _id: string;
                    content_type: string;
                    deleted?: null | boolean;
                    filename: string;
                    message_id?: null | string;
                    metadata: {
                        type: "File";
                    } | {
                        type: "Text";
                    } | {
                        height: number;
                        type: "Image";
                        width: number;
                    } | {
                        height: number;
                        type: "Video";
                        width: number;
                    } | {
                        type: "Audio";
                    };
                    object_id?: null | string;
                    reported?: null | boolean;
                    server_id?: null | string;
                    size: number;
                    tag: string;
                    user_id?: null | string;
                };
                content?: null | string;
            };
            relations?: null | {
                _id: string;
                status: "User" | "None" | "Friend" | "Outgoing" | "Incoming" | "Blocked" | "BlockedOther";
            }[];
            relationship?: null | "User" | "None" | "Friend" | "Outgoing" | "Incoming" | "Blocked" | "BlockedOther";
            status?: null | {
                presence?: null | "Online" | "Idle" | "Focus" | "Busy" | "Invisible";
                text?: null | string;
            };
            username: string;
        }[];
    }>

Generated using TypeDoc