channel

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageOption

type MessageOption func(*createMessage)

MessageOption allows to customize the content of a message.

func WithMessageContent

func WithMessageContent(text string) MessageOption

WithMessageContent sets the content of a message, up to 2000 characters

func WithMessageEmbed

func WithMessageEmbed(e *discord.MessageEmbed) MessageOption

WithMessageEmbed sets the embed of a message. See embed sub package for more information about embeds.

func WithMessageFiles

func WithMessageFiles(files ...*discord.File) MessageOption

WithMessageFiles attach files to a message.

func WithMessageNonce

func WithMessageNonce(n string) MessageOption

WithMessageNonce sets the nonce of a message. The nonce will be returned in the result and also transmitted to other clients.

func WithMessageTTS

func WithMessageTTS() MessageOption

WithMessageTTS enables text to speech for a message.

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

Resource is a resource that allows to perform various actions on a Discord channel. Create one with Client.Channel.

func NewResource

func NewResource(c resource.RestClient, id string) *Resource

func (*Resource) AddReaction

func (r *Resource) AddReaction(ctx context.Context, messageID, emoji string) error

AddReaction adds a reaction to a message in the channel. This endpoint requires the 'READ_MESSAGE_HISTORY' permission to be present on the current user. Additionally, if nobody else has reacted to the message using this emoji, this endpoint requires the 'ADD_REACTIONS' permission to be present on the current user.

func (*Resource) CrossPostMessage

func (r *Resource) CrossPostMessage(ctx context.Context, messageID string) (*discord.Message, error)

Crosspost a message in a News Channel to following channels.

func (*Resource) Delete

func (r *Resource) Delete(ctx context.Context) (*discord.Channel, error)

Delete is like DeleteWithReason but with no particular reason.

func (*Resource) DeleteMessage

func (r *Resource) DeleteMessage(ctx context.Context, messageID string) error

DeleteMessage is like DeleteMessageWithReason but with no particular reason.

func (*Resource) DeleteMessageBulk

func (r *Resource) DeleteMessageBulk(ctx context.Context, messageIDs []string) error

DeleteMessageBulk deletes multiple messages in a single request. This endpoint can only be used on guild channels and requires the 'MANAGE_MESSAGES' permission. Fires multiple Message Delete Gateway events. Any message IDs given that do not exist or are invalid will count towards the minimum and maximum message count (currently 2 and 100 respectively). Additionally, duplicated IDs will only be counted once. This endpoint will not delete messages older than 2 weeks, and will fail if any message provided is older than that.

func (*Resource) DeleteMessageWithReason

func (r *Resource) DeleteMessageWithReason(ctx context.Context, messageID, reason string) error

DeleteMessageWithReason deletes a message. If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the 'MANAGE_MESSAGES' permission. Fires a Message Delete Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) DeletePermission

func (r *Resource) DeletePermission(ctx context.Context, channelID, targetID string) error

DeletePermission is like DeletePermissionWithReason but with no particular reason.

func (*Resource) DeletePermissionWithReason

func (r *Resource) DeletePermissionWithReason(ctx context.Context, channelID, targetID, reason string) error

DeletePermissionWithReason deletes the channel permission overwrite for a user or role in a channel. Only usable for guild channels. Requires the 'MANAGE_ROLES' permission. The given reason will be set in the audit log entry for this action.

func (*Resource) DeleteWithReason

func (r *Resource) DeleteWithReason(ctx context.Context, reason string) (*discord.Channel, error)

DeleteWithReason deletes the channel, or closes the private message. Requires the 'MANAGE_CHANNELS' permission for the discord. Deleting a category does not delete its child channels; they will have their parent_id removed and a Channel Update Gateway event will fire for each of them. Returns the deleted channel on success. Fires a Channel Delete Gateway event. The given reason will be set in the audit log entry for this action.

func (*Resource) EditEmbed

func (r *Resource) EditEmbed(ctx context.Context, messageID, content string, embed *discord.MessageEmbed) (*discord.Message, error)

EditEmbed is like EditMessage but with embedded content support.

func (*Resource) EditMessage

func (r *Resource) EditMessage(ctx context.Context, messageID, content string) (*discord.Message, error)

EditMessage edits a previously sent message. You can only edit messages that have been sent by the current user. Fires a Message Update Gateway event. See EditEmbed if you need to edit some emended content.

func (*Resource) Get

func (r *Resource) Get(ctx context.Context) (*discord.Channel, error)

Get returns the channel.

func (*Resource) Invites

func (r *Resource) Invites(ctx context.Context) ([]discord.Invite, error)

Invites returns a list of invites (with invite metadata) for the channel. Only usable for guild channels. Requires the 'MANAGE_CHANNELS' permission.

func (*Resource) Message

func (r *Resource) Message(ctx context.Context, id string) (*discord.Message, error)

Message returns a specific message in the channel. If operating on a guild channel, this endpoints requires the 'READ_MESSAGE_HISTORY' permission to be present on the current user.

func (*Resource) Messages

func (r *Resource) Messages(ctx context.Context, query string, limit int) ([]discord.Message, error)

Messages returns messages in the channel. If operating on a guild channel, this endpoint requires the 'VIEW_CHANNEL' permission to be present on the current user. If the current user is missing the 'READ_MESSAGE_HISTORY' permission in the channel then this will return no messages (since they cannot read the message history). The query parameter is a message ID prefixed with one of the following character:

  • '>' for fetching messages after
  • '<' for fetching messages before
  • '~' for fetching messages around

For example, to retrieve 50 messages around (25 before, 25 after) a message having the ID 221588207995121520, set query to "~221588207995121520". Limit is a positive integer between 1 and 100 that defaults to 50 if set to 0.

func (*Resource) Modify

func (r *Resource) Modify(ctx context.Context, settings *discord.ChannelSettings) (*discord.Channel, error)

Modify is like ModifyWithReason but with no particular reason.

func (*Resource) ModifyWithReason

func (r *Resource) ModifyWithReason(ctx context.Context, settings *discord.ChannelSettings, reason string) (*discord.Channel, error)

ModifyWithReason updates the channel's settings. Requires the 'MANAGE_CHANNELS' permission for the discord. Fires a Channel Update Gateway event. If modifying category, individual Channel Update events will fire for each child channel that also changes. The given reason will be set in the audit log entry for this action.

func (*Resource) NewInvite

func (r *Resource) NewInvite(ctx context.Context, settings *discord.InviteSettings) (*discord.Invite, error)

NewInvite is like NewInviteWithReason but with no particular reason.

func (*Resource) NewInviteWithReason

func (r *Resource) NewInviteWithReason(ctx context.Context, settings *discord.InviteSettings, reason string) (*discord.Invite, error)

NewInviteWithReason creates a new invite for the channel. Only usable for guild channels. Requires the CREATE_INSTANT_INVITE permission. The given reason will be set in the audit log entry for this action.

func (*Resource) NewWebhook

func (r *Resource) NewWebhook(ctx context.Context, name, avatar string) (*discord.Webhook, error)

NewWebhook is like NewWebhookWithReason but with no particular reason.

func (*Resource) NewWebhookWithReason

func (r *Resource) NewWebhookWithReason(ctx context.Context, name, avatar, reason string) (*discord.Webhook, error)

NewWebhookWithReason creates a new webhook for the channel. Requires the 'MANAGE_WEBHOOKS' permission. name must contain between 2 and 32 characters. avatar is an avatar data string, see https://discord.com/developers/docs/resources/user#avatar-data for more info. It can be left empty to have the default avatar. The given reason will be set in the audit log entry for this action.

func (*Resource) PinMessage

func (r *Resource) PinMessage(ctx context.Context, id string) error

PinMessage pins a message in the channel. Requires the 'MANAGE_MESSAGES' permission.

func (*Resource) Pins

func (r *Resource) Pins(ctx context.Context) ([]discord.Message, error)

Pins returns all pinned messages in the channel as an array of messages.

func (*Resource) Reactions

func (r *Resource) Reactions(ctx context.Context, messageID, emoji string, limit int, before, after string) ([]discord.User, error)

Reactions returns a list of users that reacted to a message with the given emoji. limit is the number of users to return and can be set to any value ranging from 1 to 100. If set to 0, it defaults to 25. If more than 100 users reacted with the given emoji, the before and after parameters can be used to fetch more users.

func (*Resource) RemoveAllReactions

func (r *Resource) RemoveAllReactions(ctx context.Context, messageID string) error

RemoveAllReactions removes all reactions on a message. This endpoint requires the 'MANAGE_MESSAGES' permission to be present on the current user.

func (*Resource) RemoveAllReactionsForEmoji

func (r *Resource) RemoveAllReactionsForEmoji(ctx context.Context, messageID, emoji string) error

RemoveAllReactionsForEmoji removes all reactions for the given emoji on a message. This endpoint requires the 'MANAGE_MESSAGES' permission to be present on the current user.

func (*Resource) RemoveReaction

func (r *Resource) RemoveReaction(ctx context.Context, messageID, emoji string) error

RemoveReaction removes a reaction the current user has made for the message.

func (*Resource) RemoveUserReaction

func (r *Resource) RemoveUserReaction(ctx context.Context, messageID, userID, emoji string) error

RemoveUserReaction removes another user's reaction. This endpoint requires the 'MANAGE_MESSAGES' permission to be present on the current user.

func (*Resource) Send

func (r *Resource) Send(ctx context.Context, opts ...MessageOption) (*discord.Message, error)

Send sends a message to the channel. If operating on a guild channel, this endpoint requires the 'SEND_MESSAGES' permission to be present on the current user. If the option WithMessageTTS is set, the 'SEND_TTS_MESSAGES' permission is required for the message to be spoken. Returns the message sent. Fires a Message Create Gateway event. Before using this endpoint, you must connect to the gateway at least once.

func (*Resource) SendMessage

func (r *Resource) SendMessage(ctx context.Context, text string) (*discord.Message, error)

SendMessage is a shorthand for Send(ctx, WithMessageContent(text)).

func (*Resource) TriggerTyping

func (r *Resource) TriggerTyping(ctx context.Context) error

TriggerTyping triggers a typing indicator for the channel. Generally bots should not implement this route. However, if a bot is responding to a command and expects the computation to take a few seconds, this endpoint may be called to let the user know that the bot is processing their message. Fires a Typing Start Gateway event.

func (*Resource) UnpinMessage

func (r *Resource) UnpinMessage(ctx context.Context, id string) error

UnpinMessage deletes a pinned message in the channel. Requires the 'MANAGE_MESSAGES' permission.

func (*Resource) UpdatePermissions

func (r *Resource) UpdatePermissions(ctx context.Context, perms discord.PermissionOverwrite) error

UpdatePermissions is like UpdatePermissionsWithReason but with no particular reason.

func (*Resource) UpdatePermissionsWithReason

func (r *Resource) UpdatePermissionsWithReason(ctx context.Context, perms discord.PermissionOverwrite, reason string) error

UpdatePermissionsWithReason updates the channel permission overwrites for a user or role in the channel. If the channel permission overwrites do not not exist, they are created. Only usable for guild channels. Requires the 'MANAGE_ROLES' permission. The given reason will be set in the audit log entry for this action.

func (*Resource) Webhooks

func (r *Resource) Webhooks(ctx context.Context) ([]discord.Webhook, error)

Webhooks returns webhooks for the channel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL