stoatbot.js
    Preparing search index...

    Class GroupChannel

    Represents a group channel, which allows multiple users to communicate.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    • Creates a new GroupChannel instance.

      Parameters

      • client: client

        The client instance.

      • data: {
            _id: string;
            channel_type: "Group";
            description?: string | null;
            icon?:
                | {
                    _id: string;
                    content_type: string;
                    deleted?: boolean
                    | null;
                    filename: string;
                    message_id?: string | null;
                    metadata:
                        | { type: "File" }
                        | { type: "Text" }
                        | { height: number; type: "Image"; width: number }
                        | { height: number; type: "Video"; width: number }
                        | { type: "Audio" };
                    object_id?: string | null;
                    reported?: boolean | null;
                    server_id?: string | null;
                    size: number;
                    tag: string;
                    user_id?: string | null;
                }
                | null;
            last_message_id?: string
            | null;
            name: string;
            nsfw?: boolean;
            owner: string;
            permissions?: number | null;
            recipients: string[];
        }

        The raw data for the group channel from the API.

        • _id: string

          Unique Id

        • channel_type: "Group"
        • Optionaldescription?: string | null

          Channel description

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

          Custom icon attachment

        • Optionallast_message_id?: string | null

          Id of the last message sent in this channel

        • name: string

          Display name of the channel

        • Optionalnsfw?: boolean

          Whether this group is marked as not safe for work

        • owner: string

          User id of the owner of the group

        • Optionalpermissions?: number | null

          Format: int64

          Permissions assigned to members of this group (does not apply to the owner of the group)

        • recipients: string[]

          Array of user ids participating in channel

      Returns GroupChannel

    Properties

    client: client

    The client instance.

    description: string | null = null

    The description of the group channel, if any.

    icon: Attachment | null = null

    The icon of the group channel, if any.

    id: string

    The unique identifier for the object.

    lastMessageId: string | null = null

    The ID of the last message sent in this group channel, if any.

    messages: MessageManager = ...

    Manages the messages in this group channel.

    name: string

    The name of the group channel.

    nsfw: boolean = false

    Whether the group channel is marked as NSFW (Not Safe For Work).

    ownerId: string

    The ID of the user who owns the group channel.

    The permissions for the group channel.

    type: GROUP = ChannelTypes.GROUP

    The type of the channel, which is always GROUP for group channels.

    users: Map<string, User> = ...

    A map of user IDs to their corresponding User instances in the group channel.

    Accessors

    Methods

    • Deletes the current channel instance from the client's channel collection.

      This method interacts with the client's channel management system to remove the channel. Once deleted, the channel will no longer be accessible through the client.

      Returns Promise<void>

      A promise that resolves when the channel has been successfully deleted.

      const channel = client.channels.get('1234567890');
      if (channel) {
      await channel.delete();
      console.log('Channel deleted successfully.');
      }
    • Deletes a webhook.

      Parameters

      • webhookId: string

        The ID of the webhook to delete

      • token: string

        The token of the webhook

      Returns Promise<void>

      Promise that resolves when the webhook is deleted

      await channel.deleteWebhook("webhookId", "webhookToken");
      console.log("Webhook deleted successfully");
    • Sends a message through a webhook in this channel.

      Parameters

      • webhookId: string

        The ID of the webhook to send the message through

      • token: string

        The token of the webhook

      • content: string | MessageOptions

        The message content. Can be a string or MessageOptions object with attachments and embeds

      Returns Promise<
          {
              _id: string;
              attachments?: | {
                  _id: string;
                  content_type: string;
                  deleted?: boolean
                  | null;
                  filename: string;
                  message_id?: string | null;
                  metadata:
                      | { type: "File" }
                      | { type: "Text" }
                      | { height: number; type: "Image"; width: number }
                      | { height: number; type: "Video"; width: number }
                      | { type: "Audio" };
                  object_id?: string | null;
                  reported?: boolean | null;
                  server_id?: string | null;
                  size: number;
                  tag: string;
                  user_id?: string | null;
              }[]
              | null;
              author: string;
              channel: string;
              content?: string
              | null;
              edited?: string | null;
              embeds?:
                  | (
                      | {
                          colour?: string
                          | null;
                          description?: string | null;
                          icon_url?: string | null;
                          image?:
                              | {
                                  height: number;
                                  size: "Large"
                                  | "Preview";
                                  url: string;
                                  width: number;
                              }
                              | null;
                          original_url?: string
                          | null;
                          site_name?: string | null;
                          special?:
                              | { type: "None" }
                              | { type: "GIF" }
                              | { id: string; timestamp?: string | null; type: "YouTube" }
                              | { content_type: "Channel"; id: string; type: "Lightspeed" }
                              | {
                                  content_type: "Video" | "Channel" | "Clip";
                                  id: string;
                                  type: "Twitch";
                              }
                              | { content_type: string; id: string; type: "Spotify" }
                              | { type: "Soundcloud" }
                              | { content_type: "Album" | "Track"; id: string; type: "Bandcamp" }
                              | { album_id: string; track_id?: string | null; type: "AppleMusic" }
                              | { id: string; type: "Streamable" }
                              | null;
                          title?: string | null;
                          type: "Website";
                          url?: string | null;
                          video?: { height: number; url: string; width: number } | null;
                      }
                      | {
                          height: number;
                          size: "Large"
                          | "Preview";
                          type: "Image";
                          url: string;
                          width: number;
                      }
                      | { height: number; type: "Video"; url: string; width: number }
                      | {
                          colour?: string | null;
                          description?: string | null;
                          icon_url?: string | null;
                          media?:
                              | {
                                  _id: string;
                                  content_type: string;
                                  deleted?: boolean
                                  | null;
                                  filename: string;
                                  message_id?: string | null;
                                  metadata:
                                      | { type: "File" }
                                      | { type: "Text" }
                                      | { height: number; type: "Image"; width: number }
                                      | { height: number; type: "Video"; width: number }
                                      | { type: "Audio" };
                                  object_id?: string | null;
                                  reported?: boolean | null;
                                  server_id?: string | null;
                                  size: number;
                                  tag: string;
                                  user_id?: string | null;
                              }
                              | null;
                          title?: string
                          | null;
                          type: "Text";
                          url?: string | null;
                      }
                      | { type: "None" }
                  )[]
                  | null;
              flags?: number;
              interactions?: {
                  reactions?: string[] | null;
                  restrict_reactions?: boolean;
              };
              masquerade?: | {
                  avatar?: string
                  | null;
                  colour?: string | null;
                  name?: string | null;
              }
              | null;
              member?: | {
                  _id: { server: string; user: string };
                  avatar?:
                      | {
                          _id: string;
                          content_type: string;
                          deleted?: boolean
                          | null;
                          filename: string;
                          message_id?: string | null;
                          metadata:
                              | { type: "File" }
                              | { type: "Text" }
                              | { height: number; type: "Image"; width: number }
                              | { height: number; type: "Video"; width: number }
                              | { type: "Audio" };
                          object_id?: string | null;
                          reported?: boolean | null;
                          server_id?: string | null;
                          size: number;
                          tag: string;
                          user_id?: string | null;
                      }
                      | null;
                  joined_at: string;
                  nickname?: string
                  | null;
                  roles?: string[];
                  timeout?: string | null;
              }
              | null;
              mentions?: string[]
              | null;
              nonce?: string | null;
              pinned?: boolean | null;
              reactions?: { [key: string]: string[] };
              replies?: string[] | null;
              role_mentions?: string[] | null;
              system?:
                  | { 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" }
                  | { by: string; id: string; type: "message_pinned" }
                  | { by: string; id: string; type: "message_unpinned" }
                  | null;
              user?:
                  | {
                      _id: string;
                      avatar?: | {
                          _id: string;
                          content_type: string;
                          deleted?: boolean
                          | null;
                          filename: string;
                          message_id?: string | null;
                          metadata:
                              | { type: "File" }
                              | { type: "Text" }
                              | { height: number; type: "Image"; width: number }
                              | { height: number; type: "Video"; width: number }
                              | { type: "Audio" };
                          object_id?: string | null;
                          reported?: boolean | null;
                          server_id?: string | null;
                          size: number;
                          tag: string;
                          user_id?: string | null;
                      }
                      | null;
                      badges?: number;
                      bot?: { owner: string }
                      | null;
                      discriminator: string;
                      display_name?: string | null;
                      flags?: number;
                      online: boolean;
                      privileged?: boolean;
                      relations?: {
                          _id: string;
                          status:
                              | "User"
                              | "None"
                              | "Friend"
                              | "Outgoing"
                              | "Incoming"
                              | "Blocked"
                              | "BlockedOther";
                      }[];
                      relationship: | "User"
                      | "None"
                      | "Friend"
                      | "Outgoing"
                      | "Incoming"
                      | "Blocked"
                      | "BlockedOther";
                      status?: | {
                          presence?: "Online"
                          | "Idle"
                          | "Focus"
                          | "Busy"
                          | "Invisible"
                          | null;
                          text?: string | null;
                      }
                      | null;
                      username: string;
                  }
                  | null;
              webhook?: { avatar?: string | null; name: string }
              | null;
          },
      >

      Promise resolving to the sent message

      // Send a simple text message
      await channel.sendWebhookMessage("webhookId", "token", "Hello, world!");

      // Send a message with embeds and attachments
      await channel.sendWebhookMessage("webhookId", "token", {
      content: "Check out this image!",
      attachments: ["https://example.com/image.png"],
      embeds: [myEmbed]
      });
    • Sets default permissions for this channel.

      Parameters

      • allow:
            | (
                | "ManageChannel"
                | "ManageServer"
                | "ManagePermissions"
                | "ManageRole"
                | "ManageCustomisation"
                | "KickMembers"
                | "BanMembers"
                | "TimeoutMembers"
                | "AssignRoles"
                | "ChangeNickname"
                | "ManageNicknames"
                | "ChangeAvatar"
                | "RemoveAvatars"
                | "ViewChannel"
                | "ReadMessageHistory"
                | "SendMessage"
                | "ManageMessages"
                | "ManageWebhooks"
                | "InviteOthers"
                | "SendEmbeds"
                | "UploadFiles"
                | "Masquerade"
                | "React"
                | "Connect"
                | "Speak"
                | "Video"
                | "MuteMembers"
                | "DeafenMembers"
                | "MoveMembers"
                | "MentionEveryone"
                | "MentionRoles"
                | "GrantAll"
            )[]
            | undefined

        Array of permissions to allow by default.

      Returns Promise<void>

      A promise that resolves when the permissions have been updated.

      If the channel ID is invalid.

      // Allow specific permissions
      await channel.setDefaultPermissions(["ViewChannel", "SendMessage"]);
    • Sets default permissions for this channel.

      Parameters

      • options: {
            allow?: (
                | "ManageChannel"
                | "ManageServer"
                | "ManagePermissions"
                | "ManageRole"
                | "ManageCustomisation"
                | "KickMembers"
                | "BanMembers"
                | "TimeoutMembers"
                | "AssignRoles"
                | "ChangeNickname"
                | "ManageNicknames"
                | "ChangeAvatar"
                | "RemoveAvatars"
                | "ViewChannel"
                | "ReadMessageHistory"
                | "SendMessage"
                | "ManageMessages"
                | "ManageWebhooks"
                | "InviteOthers"
                | "SendEmbeds"
                | "UploadFiles"
                | "Masquerade"
                | "React"
                | "Connect"
                | "Speak"
                | "Video"
                | "MuteMembers"
                | "DeafenMembers"
                | "MoveMembers"
                | "MentionEveryone"
                | "MentionRoles"
                | "GrantAll"
            )[];
            deny?: (
                | "ManageChannel"
                | "ManageServer"
                | "ManagePermissions"
                | "ManageRole"
                | "ManageCustomisation"
                | "KickMembers"
                | "BanMembers"
                | "TimeoutMembers"
                | "AssignRoles"
                | "ChangeNickname"
                | "ManageNicknames"
                | "ChangeAvatar"
                | "RemoveAvatars"
                | "ViewChannel"
                | "ReadMessageHistory"
                | "SendMessage"
                | "ManageMessages"
                | "ManageWebhooks"
                | "InviteOthers"
                | "SendEmbeds"
                | "UploadFiles"
                | "Masquerade"
                | "React"
                | "Connect"
                | "Speak"
                | "Video"
                | "MuteMembers"
                | "DeafenMembers"
                | "MoveMembers"
                | "MentionEveryone"
                | "MentionRoles"
                | "GrantAll"
            )[];
        }

        Object containing allow and/or deny permissions.

      Returns Promise<void>

      A promise that resolves when the permissions have been updated.

      If the channel ID is invalid or if both allow and deny are undefined.

      // Allow specific permissions only
      await channel.setDefaultPermissions({ allow: ["ViewChannel", "SendMessage"] });

      // Deny specific permissions only
      await channel.setDefaultPermissions({ deny: ["ManageMessages"] });

      // Set both allow and deny permissions
      await channel.setDefaultPermissions({
      allow: ["ViewChannel"],
      deny: ["ManageMessages"]
      });
    • Sets default permissions for this channel (legacy format).

      Parameters

      Returns Promise<void>

      A promise that resolves when the permissions have been updated.

      If the channel ID is invalid.

      // Legacy format
      await channel.setDefaultPermissions({
      a: ["ViewChannel"],
      d: ["ManageMessages"]
      });
    • Sets role permissions for this channel.

      Parameters

      • roleId: string

        The ID of the role to set permissions for.

      • allow:
            | (
                | "ManageChannel"
                | "ManageServer"
                | "ManagePermissions"
                | "ManageRole"
                | "ManageCustomisation"
                | "KickMembers"
                | "BanMembers"
                | "TimeoutMembers"
                | "AssignRoles"
                | "ChangeNickname"
                | "ManageNicknames"
                | "ChangeAvatar"
                | "RemoveAvatars"
                | "ViewChannel"
                | "ReadMessageHistory"
                | "SendMessage"
                | "ManageMessages"
                | "ManageWebhooks"
                | "InviteOthers"
                | "SendEmbeds"
                | "UploadFiles"
                | "Masquerade"
                | "React"
                | "Connect"
                | "Speak"
                | "Video"
                | "MuteMembers"
                | "DeafenMembers"
                | "MoveMembers"
                | "MentionEveryone"
                | "MentionRoles"
                | "GrantAll"
            )[]
            | undefined

        Array of permissions to allow for the role.

      Returns Promise<void>

      A promise that resolves when the permissions have been updated.

      If the channel ID is invalid.

      // Allow specific permissions
      await channel.setRolePermissions(roleId, ["ViewChannel", "SendMessage"]);
    • Sets role permissions for this channel.

      Parameters

      • roleId: string

        The ID of the role to set permissions for.

      • allow:
            | (
                | "ManageChannel"
                | "ManageServer"
                | "ManagePermissions"
                | "ManageRole"
                | "ManageCustomisation"
                | "KickMembers"
                | "BanMembers"
                | "TimeoutMembers"
                | "AssignRoles"
                | "ChangeNickname"
                | "ManageNicknames"
                | "ChangeAvatar"
                | "RemoveAvatars"
                | "ViewChannel"
                | "ReadMessageHistory"
                | "SendMessage"
                | "ManageMessages"
                | "ManageWebhooks"
                | "InviteOthers"
                | "SendEmbeds"
                | "UploadFiles"
                | "Masquerade"
                | "React"
                | "Connect"
                | "Speak"
                | "Video"
                | "MuteMembers"
                | "DeafenMembers"
                | "MoveMembers"
                | "MentionEveryone"
                | "MentionRoles"
                | "GrantAll"
            )[]
            | undefined

        Array of permissions to allow for the role.

      • deny:
            | (
                | "ManageChannel"
                | "ManageServer"
                | "ManagePermissions"
                | "ManageRole"
                | "ManageCustomisation"
                | "KickMembers"
                | "BanMembers"
                | "TimeoutMembers"
                | "AssignRoles"
                | "ChangeNickname"
                | "ManageNicknames"
                | "ChangeAvatar"
                | "RemoveAvatars"
                | "ViewChannel"
                | "ReadMessageHistory"
                | "SendMessage"
                | "ManageMessages"
                | "ManageWebhooks"
                | "InviteOthers"
                | "SendEmbeds"
                | "UploadFiles"
                | "Masquerade"
                | "React"
                | "Connect"
                | "Speak"
                | "Video"
                | "MuteMembers"
                | "DeafenMembers"
                | "MoveMembers"
                | "MentionEveryone"
                | "MentionRoles"
                | "GrantAll"
            )[]
            | undefined

        Array of permissions to deny for the role.

      Returns Promise<void>

      A promise that resolves when the permissions have been updated.

      If the channel ID is invalid.

      // Set both allow and deny permissions
      await channel.setRolePermissions(roleId, ["ViewChannel"], ["ManageMessages"]);
    • Sets role permissions for this channel.

      Parameters

      • roleId: string

        The ID of the role to set permissions for.

      • options: {
            allow?: (
                | "ManageChannel"
                | "ManageServer"
                | "ManagePermissions"
                | "ManageRole"
                | "ManageCustomisation"
                | "KickMembers"
                | "BanMembers"
                | "TimeoutMembers"
                | "AssignRoles"
                | "ChangeNickname"
                | "ManageNicknames"
                | "ChangeAvatar"
                | "RemoveAvatars"
                | "ViewChannel"
                | "ReadMessageHistory"
                | "SendMessage"
                | "ManageMessages"
                | "ManageWebhooks"
                | "InviteOthers"
                | "SendEmbeds"
                | "UploadFiles"
                | "Masquerade"
                | "React"
                | "Connect"
                | "Speak"
                | "Video"
                | "MuteMembers"
                | "DeafenMembers"
                | "MoveMembers"
                | "MentionEveryone"
                | "MentionRoles"
                | "GrantAll"
            )[];
            deny?: (
                | "ManageChannel"
                | "ManageServer"
                | "ManagePermissions"
                | "ManageRole"
                | "ManageCustomisation"
                | "KickMembers"
                | "BanMembers"
                | "TimeoutMembers"
                | "AssignRoles"
                | "ChangeNickname"
                | "ManageNicknames"
                | "ChangeAvatar"
                | "RemoveAvatars"
                | "ViewChannel"
                | "ReadMessageHistory"
                | "SendMessage"
                | "ManageMessages"
                | "ManageWebhooks"
                | "InviteOthers"
                | "SendEmbeds"
                | "UploadFiles"
                | "Masquerade"
                | "React"
                | "Connect"
                | "Speak"
                | "Video"
                | "MuteMembers"
                | "DeafenMembers"
                | "MoveMembers"
                | "MentionEveryone"
                | "MentionRoles"
                | "GrantAll"
            )[];
        }

        Object containing allow and/or deny permissions.

      Returns Promise<void>

      A promise that resolves when the permissions have been updated.

      If the channel ID is invalid or if both allow and deny are undefined.

      // Allow specific permissions only
      await channel.setRolePermissions(roleId, { allow: ["ViewChannel", "SendMessage"] });

      // Deny specific permissions only
      await channel.setRolePermissions(roleId, { deny: ["ManageMessages"] });

      // Set both allow and deny permissions
      await channel.setRolePermissions(roleId, {
      allow: ["ViewChannel"],
      deny: ["ManageMessages"]
      });