Pin a message within a channel
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 |
// Pin a message because it was a good meme
const client = new SnowTransfer("TOKEN")
client.channel.addChannelPinnedMessage("channel id", "message id", "Good meme")
Id of the channel
Id of the message
Optional
reason: stringReason for pinning the message
Add a user to a thread
CurrentUser must be a member of the thread
Resolves the Promise on successful execution
Permissions needed | Condition |
---|---|
CurrentUser added to Thread | always |
SEND_MESSAGES_IN_THREADS | always |
const client = new SnowTransfer("TOKEN")
client.channel.addThreadMember("thread id", "user id")
Id of the thread
Id of the user to add
Bulk delete messages from a guild channel, messages may not be older than 2 weeks
Resolves the Promise on successful execution
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
MANAGE_MESSAGES | always |
// 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")
Id of the guild channel
array of message ids to delete
Optional
reason: stringReason for deleting the messages
Create an invite for a guild channel
If no data argument is passed, the invite will be created with the defaults
Invite object (with metadata)
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
CREATE_INSTANT_INVITE | always |
// 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 })
Id of the channel
invite data (optional)
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
discord message 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 |
// 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")
// 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] })
// 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 }] })
Id of the Channel or thread to sent a message to
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
disableAdds a reaction to a message
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 |
// This example uses a discord emoji
const client = new SnowTransfer("TOKEN")
client.channel.createReaction("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))
// using a utf-8 emoji
const client = new SnowTransfer("TOKEN")
client.channel.createReaction("channel Id", "message Id", encodeURIComponent("😀"))
Id of the channel
Id of the message
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
Creates a public thread off a message in a guild channel
thread channel object
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
CREATE_PUBLIC_THREADS | always |
// 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!" })
Id of the guild channel
Id of the message
Thread meta data
Optional
auto_Optional
rate_Optional
reason?: stringCreates a thread under a guild channel without a message
thread channel object
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
CREATE_PUBLIC_THREADS | if creating a public thread |
CREATE_PRIVATE_THREADS | if creating a private thread |
// 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" })
Id of the guild channel
Thread meta data
Optional
auto_Optional
invitable?: booleanOptional
rate_Optional
reason?: stringOptional
auto_Optional
invitable?: booleanOptional
rate_Optional
reason?: stringCrosspost a message in a news channel to all following channels
discord message 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 |
// Crosspost a message
const client = new SnowTransfer("TOKEN")
client.channel.crosspostMessage("channel id", "message id")
Id of the news channel
Id of the message
Delete all reactions from a message in a guild channel
Resolves the Promise on successful execution
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
READ_MESSAGE_HISTORY | always |
MANAGE_MESSAGES | always |
const client = new SnowTransfer("TOKEN")
client.channel.deleteAllReactions("channel Id", "message Id")
Id of the guild channel
Id of the message
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.
discord channel object
Permissions needed | Condition |
---|---|
MANAGE_CHANNELS | if channel is not a DM channel |
MANAGE_THREADS | if channel is a thread |
// Deletes a channel via id because it wasn't needed anymore
const client = new SnowTransfer("TOKEN")
client.channel.deleteChannel("channel id", "No longer needed")
Id of the channel
Optional
reason: stringReason for deleting the channel
Delete a permission overwrite from a guild channel
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 |
// Deletes the permission overwrite of a user
const client = new SnowTransfer("TOKEN")
client.channel.deleteChannelPermission("channel id", "user id", "Abusing channel")
Id of the guild channel
Id of the permission overwrite
Optional
reason: stringReason for deleting the permission
Delete a message
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 |
// Delete a message
const client = new SnowTransfer("TOKEN")
client.channel.deleteMessage("channel id", "message id")
Id of the channel
Id of the message
Optional
reason: stringReason for deleting the message
Delete a reaction from a message in a guild channel
Resolves the Promise on successful execution
Permission | Condition |
---|---|
MANAGE_MESSAGES | always |
VIEW_CHANNEL | always |
READ_MESSAGE_HISTORY | always |
// This example uses a discord emoji
const client = new SnowTransfer("TOKEN")
client.channel.deleteReaction("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"), "user Id")
// 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("😀"))
Id of the guild channel
Id of the message
reaction emoji
Optional
userId: stringId of the user
Delete a reaction added by the current user from a message
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 |
// This example uses a discord emoji
const client = new SnowTransfer("TOKEN")
client.channel.deleteReactionSelf("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))
// using a utf-8 emoji
const client = new SnowTransfer("TOKEN")
client.channel.deleteReactionSelf("channel Id", "message Id", encodeURIComponent("😀"))
Id of the channel
Id of the message
reaction emoji
Modify the permission overwrites of a guild channel
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 |
// 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 })
Id of the guild channel
Id of the permission overwrite
modified permission overwrite object
Edit a message sent by the current user or edit the message flags of another user's message
discord message object
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | if channel is not a DM channel |
MANAGE_MESSAGES | When editing someone else's message to set flags |
// 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
)
Id of the channel
Id of the message
Data to send
Optional
disableFollow a news channel to another channel
A followed channel object
Permissions needed | Condition |
---|---|
MANAGE_WEBHOOKS | always |
// Follows a news channel to a text channel
const client = new SnowTransfer("TOKEN")
client.channel.followNewsChannel("news channel id", "text channel id")
The Id of the news channel
The Id of the channel messages will be sent to
Get a channel via Id
discord channel object
const client = new SnowTransfer("TOKEN")
const channel = await client.channel.getChannel("channel id")
Id of the channel
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
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 |
const client = new SnowTransfer("TOKEN")
const result = await client.channel.getChannelArchivedPrivateThreads("channel id")
Id of the Channel
Optional
query: { Optional
before?: stringOptional
limit?: numberGets 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
Object containing private threads, thread members of the CurrentUser, and if there are more results in the pagination
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
const client = new SnowTransfer("TOKEN")
const result = await client.channel.getChannelArchivedPrivateThreadsUser("channel id")
Id of the Channel
Optional
query: { Optional
before?: stringOptional
limit?: numberGets all threads that are public and archived within a guild channel
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 |
const client = new SnowTransfer("TOKEN")
const result = await client.channel.getChannelArchivedPublicThreads("channel id")
Id of the guild channel
Optional
query: { Optional
before?: stringOptional
limit?: numberGet a list of invites for a guild channel
Array of invite objects (with metadata)
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
MANAGE_CHANNELS | always |
const client = new SnowTransfer("TOKEN")
const invites = await client.channel.getChannelInvites("channel id")
Id of the guild channel
Get a single message via Id
discord message 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 single message from a channel via id
const client = new SnowTransfer("TOKEN")
const message = await client.channel.getChannelMessage("channel id", "message id")
Id of the channel
Id of the message
Get a list of messages from a channel
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 |
// 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)
Id of the channel
Get a list of pinned messages for a channel
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 |
const client = new SnowTransfer("TOKEN")
const messages = await client.channel.getPinnedMessages("channel id")
Id of the channel
Get a list of users that reacted with a certain emoji on a certain message
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 |
// This example uses a discord emoji
const client = new SnowTransfer("TOKEN")
const reactions = await client.channel.getReactions("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))
Id of the channel
Id of the message
reaction emoji
Optional
query: { Options for getting users
Optional
after?: stringOptional
limit?: numberGets a member of a thread
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
const client = new SnowTransfer("TOKEN")
const member = await client.channel.getThreadMember("thread id", "user id")
Id of the thread
Id of the user
Gets all members within a thread
Array of thread members
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
Intents |
---|
GUILD_MEMBERS |
const client = new SnowTransfer("TOKEN")
const members = await client.channel.getThreadMembers("thread id")
Id of the Thread
Join a thread
Resolves the Promise on successful execution
Permissions needed | Condition |
---|---|
VIEW_CHANNEL | always |
const client = new SnowTransfer("TOKEN")
client.channel.joinThread("thread id")
Id of the thread
Remove a pinned message from a channel
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 |
// Remove a pinned message because mod abuse :(
const client = new SnowTransfer("TOKEN")
client.channel.removeChannelPinnedMessage("channel id", "message id", "Mod abuse")
Id of the channel
Id of the message
Optional
reason: stringReason for removing the pinned message
Remove a user from a thread
Resolves the Promise on successful execution
Permissions needed | Condition |
---|---|
MANAGE_THREADS | if the current user is not the creator of the thread |
const client = new SnowTransfer("TOKEN")
client.channel.removeThreadMember("thread id", "user id")
Id of the thread
Id of the user to remove
Send an indicator that the current user is typing within a channel.
You should generally avoid this method unless used for longer computations (>1s)
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 |
const client = new SnowTransfer("TOKEN")
client.channel.sendChannelTyping("channel id")
Id of the channel
Update a guild channel or thread
discord channel object
Permissions needed | Condition |
---|---|
MANAGE_CHANNELS | always |
MANAGE_ROLES | If modifying permission overwrites |
SEND_MESSAGES | When editing a Thread to change the name, archived, auto_archive_duration, rate_limit_per_user or locked fields |
MANAGE_THREADS | When editing a Thread and not modifying the name, archived, auto_archive_duration, rate_limit_per_user or locked fields |
// This example updates a channel with the passed id to use "New Name" as its name and "Look at this cool topic" as the topic
const client = new SnowTransfer("TOKEN")
const updateData = {
name: "New Name",
topic: "Look at this cool topic"
}
client.channel.updateChannel("channel id", updateData)
Id of the guild channel
Data to send
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
request handler that calls the rest api
Disable [at]everyone/[at]here on outgoing messages
Generated using TypeDoc
Methods for interacting with Channels and Messages