Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ChannelMethods

Methods for interacting with Channels and Messages

Hierarchy

  • ChannelMethods

Index

Constructors

  • Create a new Channel Method handler

    Usually SnowTransfer creates a method handler for you, this is here for completion

    You can access the methods listed via client.channel.method, where client is an initialized SnowTransfer instance

    Parameters

    • requestHandler: <internal>.RequestHandler

      request handler that calls the rest api

    • disableEveryone: boolean

      Disable [at]everyone/[at]here on outgoing messages

    Returns <internal>.ChannelMethods

Properties

disableEveryone: boolean
requestHandler: <internal>.RequestHandler
default: typeof <internal>.ChannelMethods

Methods

  • addChannelPinnedMessage(channelId: string, messageId: string, reason?: string): Promise<void>
  • Pin a message within a channel

    example

    // Pin a message because it was a good meme const client = new SnowTransfer("TOKEN") client.channel.addChannelPinnedMessage("channel id", "message id", "Good meme")

    Parameters

    • channelId: string

      Id of the channel

    • messageId: string

      Id of the message

    • Optional reason: string

      Reason for pinning the message

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel
    MANAGE_MESSAGES if channel is not a DM channel
  • addThreadMember(threadId: string, userId: string): Promise<void>
  • Add a user to a thread

    CurrentUser must be a member of the thread

    example

    const client = new SnowTransfer("TOKEN") client.channel.addThreadMember("thread id", "user id")

    Parameters

    • threadId: string

      Id of the thread

    • userId: string

      Id of the user to add

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    CurrentUser added to Thread always
    SEND_MESSAGES_IN_THREADS always
  • bulkDeleteMessages(channelId: string, messages: string[], reason?: string): Promise<void>
  • Bulk delete messages from a guild channel, messages may not be older than 2 weeks

    example

    // Bulk deletes 2 messages with a reason of "spam" const client = new SnowTransfer("TOKEN") client.channel.bulkDeleteMessages("channel id", ["message id 1", "message id 2"], "spam")

    Parameters

    • channelId: string

      Id of the guild channel

    • messages: string[]

      array of message ids to delete

    • Optional reason: string

      Reason for deleting the messages

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    VIEW_CHANNEL always
    MANAGE_MESSAGES always
  • Create an invite for a guild channel

    If no data argument is passed, the invite will be created with the defaults

    example

    // Creates a unique permanent invite with infinite uses const client = new SnowTransfer("TOKEN") const invite = await client.channel.createChannelInvite("channel id", { max_age: 0, max_uses: 0, unique: true })

    Parameters

    Returns Promise<<internal>.Invite>

    (https://discord.com/developers/docs/resources/invite#invite-object) (with metadata)

    Permissions needed Condition
    VIEW_CHANNEL always
    CREATE_INSTANT_INVITE always
  • Creates a new Message within a channel or thread

    Make sure to use a filename with a proper extension (e.g. png, jpeg, etc.) when you want to upload files

    example

    // Make a bot say "hi" within a channel // createMessage sends the passed data as content, when you give it a string const client = new SnowTransfer("TOKEN") client.channel.createMessage("channel id", "hi")

    example

    // Send a rich embed object const client = new SnowTransfer("TOKEN") const embedData = { title: "This is a nice embed", description: "But winter is so cold", fields: [ { name: "Brr", value: "Insert snowflake emoji here" } ] } client.channel.createMessage("channel id", { embeds: [embedData] })

    example

    // Send a file with a comment const client = new SnowTransfer("TOKEN") // fileData will be a buffer with the data of the png image. const fileData = fs.readFileSync("nice_picture.png") // You should probably use fs.readFile, since it is asynchronous, synchronous methods block the thread. client.channel.createMessage("channel id", { content: "This is a nice picture", files: [{ name: "Optional_Filename.png", file: fileData }] })

    Parameters

    • channelId: string

      Id of the Channel or thread to sent a message to

    • data: string | <internal>.CreateMessageData

      Data to send, if data is a string it will be used as the content of the message, if data is not a string you should take a look at the properties below to know what you may send

    • Optional options: { disableEveryone?: boolean }
      • Optional disableEveryone?: boolean

    Returns Promise<<internal>.Message>

    (https://discord.com/developers/docs/resources/channel#message-object) object

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel and message is a reply
    SEND_MESSAGES if channel is not a DM channel and if channel is not a thread
    SEND_TTS_MESSAGES if channel is not a DM channel and tts is set to true
    SEND_MESSAGES_IN_THREADS if channel is a thread
  • createReaction(channelId: string, messageId: string, emoji: string): Promise<void>
  • Adds a reaction to a message

    example

    // This example uses a discord emoji const client = new SnowTransfer("TOKEN") client.channel.createReaction("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))

    example

    // using a utf-8 emoji const client = new SnowTransfer("TOKEN") client.channel.createReaction("channel Id", "message Id", encodeURIComponent("😀"))

    Parameters

    • channelId: string

      Id of the channel

    • messageId: string

      Id of the message

    • emoji: string

      uri encoded reaction emoji to add you may either use a discord emoji in the format :emoji_name:emoji_id or a unicode emoji, which can be found here

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel
    ADD_REACTIONS When no other user has reacted with the emoji used and channel is not a DM channel
  • createThreadWithMessage(channelId: string, messageId: string, options: { auto_archive_duration?: 60 | 1440 | 4320 | 10080; name: string; rate_limit_per_user?: null | number; reason?: string }): Promise<<internal>.NewsThread | <internal>.PublicThread>
  • Creates a public thread off a message in a guild channel

    example

    // Create a thread off a cool art piece to discuss const client = new SnowTransfer("TOKEN") const thread = await client.channel.createThreadWithMessage("channel id", "message id", { name: "cool-art", reason: "I wanna talk about it!" })

    Parameters

    • channelId: string

      Id of the guild channel

    • messageId: string

      Id of the message

    • options: { auto_archive_duration?: 60 | 1440 | 4320 | 10080; name: string; rate_limit_per_user?: null | number; reason?: string }

      Thread meta data

      • Optional auto_archive_duration?: 60 | 1440 | 4320 | 10080
      • name: string
      • Optional rate_limit_per_user?: null | number
      • Optional reason?: string

    Returns Promise<<internal>.NewsThread | <internal>.PublicThread>

    (https://discord.com/developers/docs/resources/channel#channel-object) object

    Permissions needed Condition
    VIEW_CHANNEL always
    CREATE_PUBLIC_THREADS always
  • createThreadWithoutMessage(channelId: string, options: { auto_archive_duration?: 60 | 1440 | 4320 | 10080; invitable?: boolean; name: string; rate_limit_per_user?: null | number; reason?: string; type: 11 }): Promise<<internal>.PublicThread>
  • createThreadWithoutMessage(channelId: string, options: { auto_archive_duration?: 60 | 1440 | 4320 | 10080; invitable?: boolean; name: string; rate_limit_per_user?: null | number; reason?: string; type: 12 }): Promise<<internal>.PrivateThread>
  • Creates a thread under a guild channel without a message

    example

    // Creates a private thread that's invitable to talk about someone's birthday const client = new SnowTransfer("TOKEN") const thread = await client.channel.createThreadWithoutMessage("channel id", { name: "persons-birthday", type: 12, invitable: true, reason: "Shh! It's a surprise" })

    Parameters

    • channelId: string

      Id of the guild channel

    • options: { auto_archive_duration?: 60 | 1440 | 4320 | 10080; invitable?: boolean; name: string; rate_limit_per_user?: null | number; reason?: string; type: 11 }

      Thread meta data

      • Optional auto_archive_duration?: 60 | 1440 | 4320 | 10080
      • Optional invitable?: boolean
      • name: string
      • Optional rate_limit_per_user?: null | number
      • Optional reason?: string
      • type: 11

    Returns Promise<<internal>.PublicThread>

    (https://discord.com/developers/docs/resources/channel#channel-object) object

    Permissions needed Condition
    VIEW_CHANNEL always
    CREATE_PUBLIC_THREADS if creating a public thread
    CREATE_PRIVATE_THREADS if creating a private thread
  • Parameters

    • channelId: string
    • options: { auto_archive_duration?: 60 | 1440 | 4320 | 10080; invitable?: boolean; name: string; rate_limit_per_user?: null | number; reason?: string; type: 12 }
      • Optional auto_archive_duration?: 60 | 1440 | 4320 | 10080
      • Optional invitable?: boolean
      • name: string
      • Optional rate_limit_per_user?: null | number
      • Optional reason?: string
      • type: 12

    Returns Promise<<internal>.PrivateThread>

  • Crosspost a message in a news channel to all following channels

    example

    // Crosspost a message const client = new SnowTransfer("TOKEN") client.channel.crosspostMessage("channel id", "message id")

    Parameters

    • channelId: string

      Id of the news channel

    • messageId: string

      Id of the message

    Returns Promise<<internal>.Message>

    (https://discord.com/developers/docs/resources/channel#message-object) object

    Permissions needed Condition
    VIEW_CHANNEL always
    SEND_MESSAGES if the message was sent by the current user
    MANAGE_MESSAGES if the message wasn't sent by the current user
  • deleteAllReactions(channelId: string, messageId: string): Promise<void>
  • Delete all reactions from a message in a guild channel

    example

    const client = new SnowTransfer("TOKEN") client.channel.deleteAllReactions("channel Id", "message Id")

    Parameters

    • channelId: string

      Id of the guild channel

    • messageId: string

      Id of the message

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    VIEW_CHANNEL always
    READ_MESSAGE_HISTORY always
    MANAGE_MESSAGES always
  • Delete a channel or thread via Id

    This either deletes a Guild Channel/thread or closes a Direct Message Channel

    Be careful with deleting Guild Channels as this cannot be undone!

    When deleting a category, this does not delete the child channels of a category. They will just have their parent_id removed.

    For community guilds, the rules channel and the community updates channel cannot be deleted.

    example

    // Deletes a channel via id because it wasn't needed anymore const client = new SnowTransfer("TOKEN") client.channel.deleteChannel("channel id", "No longer needed")

    Parameters

    • channelId: string

      Id of the channel

    • Optional reason: string

      Reason for deleting the channel

    Returns Promise<<internal>.Channel>

    (https://discord.com/developers/docs/resources/channel#channel-object) object

    Permissions needed Condition
    MANAGE_CHANNELS if channel is not a DM channel
    MANAGE_THREADS if channel is a thread
  • deleteChannelPermission(channelId: string, permissionId: string, reason?: string): Promise<void>
  • Delete a permission overwrite from a guild channel

    example

    // Deletes the permission overwrite of a user const client = new SnowTransfer("TOKEN") client.channel.deleteChannelPermission("channel id", "user id", "Abusing channel")

    Parameters

    • channelId: string

      Id of the guild channel

    • permissionId: string

      Id of the permission overwrite

    • Optional reason: string

      Reason for deleting the permission

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_CHANNELS if channel is not a thread
    MANAGE_THREADS if channel is a thread
    MANAGE_ROLES always
    VIEW_CHANNEL always
  • deleteMessage(channelId: string, messageId: string, reason?: string): Promise<void>
  • Delete a message

    example

    // Delete a message const client = new SnowTransfer("TOKEN") client.channel.deleteMessage("channel id", "message id")

    Parameters

    • channelId: string

      Id of the channel

    • messageId: string

      Id of the message

    • Optional reason: string

      Reason for deleting the message

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    MANAGE_MESSAGES When the bot isn't the author of the message
  • deleteReaction(channelId: string, messageId: string, emoji: string, userId?: string): Promise<void>
  • Delete a reaction from a message in a guild channel

    example

    // This example uses a discord emoji const client = new SnowTransfer("TOKEN") client.channel.deleteReaction("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"), "user Id")

    example

    // using a utf-8 emoji const client = new SnowTransfer("TOKEN") // If a user Id is not supplied, the emoji from that message will be removed for all users client.channel.deleteReaction("channel Id", "message Id", encodeURIComponent("😀"))

    Parameters

    • channelId: string

      Id of the guild channel

    • messageId: string

      Id of the message

    • emoji: string

      reaction emoji

    • Optional userId: string

      Id of the user

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permission Condition
    MANAGE_MESSAGES always
    VIEW_CHANNEL always
    READ_MESSAGE_HISTORY always
  • deleteReactionSelf(channelId: string, messageId: string, emoji: string): Promise<void>
  • Delete a reaction added by the current user from a message

    example

    // This example uses a discord emoji const client = new SnowTransfer("TOKEN") client.channel.deleteReactionSelf("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))

    example

    // using a utf-8 emoji const client = new SnowTransfer("TOKEN") client.channel.deleteReactionSelf("channel Id", "message Id", encodeURIComponent("😀"))

    Parameters

    • channelId: string

      Id of the channel

    • messageId: string

      Id of the message

    • emoji: string

      reaction emoji

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permission Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel
  • Modify the permission overwrites of a guild channel

    example

    // Edits the permissions of a user to allow viewing the channel only const client = new SnowTransfer("TOKEN") client.channel.editChannelPermission("channel id", "user id", { allow: String(1 << 10), type: 1 })

    Parameters

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_CHANNELS if channel is not a thread
    MANAGE_THREADS if channel is a thread
    MANAGE_ROLES always
    VIEW_CHANNEL always
  • Edit a message sent by the current user or edit the message flags of another user's message

    example

    // Simple ping response const client = new SnowTransfer("TOKEN") const time = Date.now() const message = await client.channel.createMessage("channel id", "pong") client.channel.editMessage("channel id", message.id, pong ${Date.now() - time}ms)

    Parameters

    • channelId: string

      Id of the channel

    • messageId: string

      Id of the message

    • data: string | <internal>.EditMessageData

      Data to send

    • Optional options: { disableEveryone?: boolean }
      • Optional disableEveryone?: boolean

    Returns Promise<<internal>.Message>

    (https://discord.com/developers/docs/resources/channel#message-object) object

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    MANAGE_MESSAGES When editing someone else's message to set flags
  • Gets all threads that are private and archived within a guild channel

    CurrentUser must be a member of the thread if they do not have MANAGE_THREADS permissions

    example

    const client = new SnowTransfer("TOKEN") const result = await client.channel.getChannelArchivedPrivateThreads("channel id")

    Parameters

    • channelId: string

      Id of the Channel

    • Optional query: { before?: string; limit?: number }
      • Optional before?: string
      • Optional limit?: number

    Returns Promise<{ has_more: boolean; members: <internal>.ThreadMember[]; threads: <internal>.PrivateThread[] }>

    Object containing private threads, thread members of the CurrentUser, and if there are more results in the pagination

    Permissions needed Condition
    VIEW_CHANNEL always
    READ_MESSAGE_HISTORY always
    MANAGE_THREADS if CurrentUser isn't added to Thread
  • Gets all threads that are private and archived within a guild channel that the CurrentUser is apart of

    CurrentUser must be a member of the thread if they do not have MANAGE_THREADS permissions

    example

    const client = new SnowTransfer("TOKEN") const result = await client.channel.getChannelArchivedPrivateThreadsUser("channel id")

    Parameters

    • channelId: string

      Id of the Channel

    • Optional query: { before?: string; limit?: number }
      • Optional before?: string
      • Optional limit?: number

    Returns Promise<{ has_more: boolean; members: <internal>.ThreadMember[]; threads: <internal>.PrivateThread[] }>

    Object containing private threads, thread members of the CurrentUser, and if there are more results in the pagination

    Permissions needed Condition
    VIEW_CHANNEL always
  • Gets all threads that are public and archived within a guild channel

    example

    const client = new SnowTransfer("TOKEN") const result = await client.channel.getChannelArchivedPublicThreads("channel id")

    Parameters

    • channelId: string

      Id of the guild channel

    • Optional query: { before?: string; limit?: number }
      • Optional before?: string
      • Optional limit?: number

    Returns Promise<{ has_more: boolean; members: <internal>.ThreadMember[]; threads: (<internal>.NewsThread | <internal>.PublicThread)[] }>

    Object containing public threads, thread members of the CurrentUser, and if there are more results in the pagination

    Permissions needed Condition
    VIEW_CHANNEL always
    READ_MESSAGE_HISTORY always
  • Get a single message via Id

    example

    // Get a single message from a channel via id const client = new SnowTransfer("TOKEN") const message = await client.channel.getChannelMessage("channel id", "message id")

    Parameters

    • channelId: string

      Id of the channel

    • messageId: string

      Id of the message

    Returns Promise<<internal>.Message>

    (https://discord.com/developers/docs/resources/channel#message-object) object

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel
  • Get a list of messages from a channel

    example

    // Fetch the last 20 messages from a channel const client = new SnowTransfer("TOKEN") const options = { limit: 20 } const messages = await client.channel.getChannelMessages("channel id", options)

    Parameters

    Returns Promise<<internal>.Message[]>

    Array of discord message objects

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel, unless you want the API to return an empty Array
  • Get a list of pinned messages for a channel

    example

    const client = new SnowTransfer("TOKEN") const messages = await client.channel.getPinnedMessages("channel id")

    Parameters

    • channelId: string

      Id of the channel

    Returns Promise<<internal>.Message[]>

    Array of message objects

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel
  • getReactions(channelId: string, messageId: string, emoji: string, query?: { after?: string; limit?: number }): Promise<<internal>.User[]>
  • Get a list of users that reacted with a certain emoji on a certain message

    example

    // This example uses a discord emoji const client = new SnowTransfer("TOKEN") const reactions = await client.channel.getReactions("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))

    Parameters

    • channelId: string

      Id of the channel

    • messageId: string

      Id of the message

    • emoji: string

      reaction emoji

    • Optional query: { after?: string; limit?: number }

      Options for getting users

      • Optional after?: string
      • Optional limit?: number

    Returns Promise<<internal>.User[]>

    Array of user objects

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel
  • Gets a member of a thread

    example

    const client = new SnowTransfer("TOKEN") const member = await client.channel.getThreadMember("thread id", "user id")

    Parameters

    • threadId: string

      Id of the thread

    • userId: string

      Id of the user

    Returns Promise<<internal>.ThreadMember>

    A thread member

    Permissions needed Condition
    VIEW_CHANNEL always
  • Gets all members within a thread

    example

    const client = new SnowTransfer("TOKEN") const members = await client.channel.getThreadMembers("thread id")

    Parameters

    • channelId: string

      Id of the Thread

    Returns Promise<<internal>.ThreadMember[]>

    Array of thread members

    Permissions needed Condition
    VIEW_CHANNEL always
    Intents
    GUILD_MEMBERS
  • joinThread(threadId: string): Promise<void>
  • Join a thread

    example

    const client = new SnowTransfer("TOKEN") client.channel.joinThread("thread id")

    Parameters

    • threadId: string

      Id of the thread

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    VIEW_CHANNEL always
  • leaveThread(threadId: string): Promise<void>
  • Leave a thread

    example

    const client = new SnowTransfer("TOKEN") client.channel.leaveThread("thread id")

    Parameters

    • threadId: string

      Id of the thread

    Returns Promise<void>

    Resolves the Promise on successful execution

  • removeChannelPinnedMessage(channelId: string, messageId: string, reason?: string): Promise<void>
  • Remove a pinned message from a channel

    example

    // Remove a pinned message because mod abuse :( const client = new SnowTransfer("TOKEN") client.channel.removeChannelPinnedMessage("channel id", "message id", "Mod abuse")

    Parameters

    • channelId: string

      Id of the channel

    • messageId: string

      Id of the message

    • Optional reason: string

      Reason for removing the pinned message

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    READ_MESSAGE_HISTORY if channel is not a DM channel
    MANAGE_MESSAGES if channel is not a DM channel
  • removeThreadMember(threadId: string, userId: string): Promise<void>
  • Remove a user from a thread

    example

    const client = new SnowTransfer("TOKEN") client.channel.removeThreadMember("thread id", "user id")

    Parameters

    • threadId: string

      Id of the thread

    • userId: string

      Id of the user to remove

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_THREADS if the current user is not the creator of the thread
  • startChannelTyping(channelId: string): Promise<void>
  • Send an indicator that the current user is typing within a channel.

    You should generally avoid this method unless used for longer computations (>1s)

    example

    const client = new SnowTransfer("TOKEN") client.channel.sendChannelTyping("channel id")

    Parameters

    • channelId: string

      Id of the channel

    Returns Promise<void>

    Resolves the Promise on successful execution

    Permissions needed Condition
    VIEW_CHANNEL if channel is not a DM channel
    SEND_MESSAGES if channel is not a thread
    SEND_MESSAGES_IN_THREADS if channel is a thread

Generated using TypeDoc