discordhook

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Unlicense Imports: 12 Imported by: 0

README

DiscordHook

Go.Dev Go Report Card

This module is made for those, who wants to only use Discord webhooks. If you want more from Discord API, i would suggest you to use disgord.

Where to find webhook ID and token

You can find them in webhook URL https://discord.com/api/webhooks/WEBHOOK_ID_HERE/WEBHOOK_TOKEN_HERE

Examples

package main

import (
    "fmt"

    "github.com/nickname32/discordhook"
)

func main() {
    wa, err := discordhook.NewWebhookAPI(12345678900987654321, "TOKENtoken1234567890asdfghjkl", true, nil)
    if err != nil {
        panic(err)
    }

    wh, err := wa.Get(nil)
    if err != nil {
        panic(err)
    }

    fmt.Println(wh.Name)

    msg, err := wa.Execute(nil, &discordhook.WebhookExecuteParams{
        Content: "Example text",
        Embeds: []*discordhook.Embed{
            {
                Title:       "Hi there",
                Description: "This is description",
            },
        },
    }, nil, "")
    if err != nil {
        panic(err)
    }

    fmt.Println(msg.ID)

    wh, err = wa.Modify(nil, &discordhook.WebhookModifyParams{
        Name: "This is a new default webhook name",
    })
    if err != nil {
        panic(err)
    }

    fmt.Println(wh)

    err = wa.Delete(nil)
    if err != nil {
        panic(err)
    }
}

Documentation

Index

Constants

View Source
const (
	// ChannelTypeChannelTypeGuildText - a text channel within a server
	ChannelTypeChannelTypeGuildText = 0
	// ChannelTypeDM - a direct message between users
	ChannelTypeDM = 1
	// ChannelTypeGuildVoice - a voice channel within a server
	ChannelTypeGuildVoice = 2
	// ChannelTypeGroupDM - a direct message between multiple users
	ChannelTypeGroupDM = 3
	// ChannelTypeGuildCATEGORY - an organizational category that contains up to 50 channels
	ChannelTypeGuildCATEGORY = 4
	// ChannelTypeGuildNews - a channel that users can follow and crosspost into their own server
	ChannelTypeGuildNews = 5
	// ChannelTypeGuildSstor - a channel in which game developers can sell their game on Discord
	ChannelTypeGuildSstor = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	// Type - type of message activity
	Type int `json:"type"`
	// PartyID - party_id from a Rich Presence event
	PartyID snowflake.Snowflake `json:"party_id,omitempty"`
}

Activity represents Message Activity Structure https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure

type AllowedMentions

type AllowedMentions struct {
	// Parse - an array of allowed mention types to parse from the content.
	Parse []MentionType `json:"parse,omitempty"`
	// Roles - an array of role_ids to mention (Max size of 100)
	Roles []snowflake.Snowflake `json:"roles,omitempty"`
	// Users - Array of user_ids to mention (Max size of 100)
	Users []snowflake.Snowflake `json:"users,omitempty"`
}

AllowedMentions allows for more granular control over mentions without various hacks to the message content. This will always validate against message content to avoid phantom pings (e.g. to ping everyone, you must still have @everyone in the message content), and check against user/bot permissions. https://discord.com/developers/docs/resources/channel#allowed-mentions-object

type Application

type Application struct {
	// ID (snowflake) - ID of the application
	ID snowflake.Snowflake `json:"id"`
	// CoverImage - ID of the embed's image asset
	CoverImage string `json:"cover_image,omitempty"`
	// Description - application's description
	Description string `json:"description"`
	// Icon - id of the application's icon
	Icon string `json:"icon"`
	// Name - name of the application
	Name string `json:"name"`
}

Application represents Message Application Structure https://discord.com/developers/docs/resources/channel#message-object-message-application-structure

type Attachment

type Attachment struct {
	// ID (snowflake) - attachment id
	ID snowflake.Snowflake `json:"id"`
	// Filenmae - name of file attached
	Filename string `json:"filename"`
	// Size - size of file in bytes
	Size int `json:"size"`
	// URL - source url of file
	URL string `json:"url"`
	// ProxyURL - a proxied url of file
	ProxyURL string `json:"proxy_url"`
	// Height - height of file (if image)
	Height int `json:"height"`
	// Width - width of file (if image)
	Width int `json:"width"`
}

Attachment represents Attachment Structure https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure

type ChannelMention

type ChannelMention struct {
	// ID (snowflake) - id of the channel
	ID snowflake.Snowflake `json:"id"`
	// GuildID (snowflake) - id of the guild containing the channel
	GuildID snowflake.Snowflake `json:"guild_id"`
	// Type - the type of channel
	Type ChannelType `json:"type"`
	// Name - the name of the channel
	Name string `json:"name"`
}

ChannelMention represents Channel Mention Structure https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure

type Embed

type Embed struct {
	// Title - title of embed
	Title string `json:"title,omitempty"`
	// Type - type of embed (always "rich" for webhook embeds)
	Type EmbedType `json:"type,omitempty"`
	// Description - description of embed
	Description string `json:"description,omitempty"`
	// URL - url of embed
	URL string `json:"url,omitempty"`
	// Timestamp - timestamp of embed content
	Timestamp *time.Time `json:"timestamp,omitempty"`
	// Color - color code of the embed
	Color int `json:"color,omitempty"`
	// Footer - footer information
	Footer *EmbedFooter `json:"footer,omitempty"`
	// Image - image information
	Image *EmbedImage `json:"image,omitempty"`
	// Thumbnail - thumbnail information
	Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"`
	// Video - video information
	Video *EmbedVideo `json:"video,omitempty"`
	// Provider - provider information
	Provider *EmbedProvider `json:"provider,omitempty"`
	// Author - author information
	Author *EmbedAuthor `json:"author,omitempty"`
	// Fields - fields information
	Fields []*EmbedField `json:"fields,omitempty"`
}

Embed - embedded `rich` content For the webhook embed objects, you can set every field except `type` (it will be rich regardless of if you try to set it), `provider`, `video`, and any `height`, `width`, or `proxy_url` values for images. https://discord.com/developers/docs/resources/channel#embed-object-embed-structure

type EmbedAuthor

type EmbedAuthor struct {
	// Name - name of author
	Name string `json:"name,omitempty"`
	// URL - url of author
	URL string `json:"url,omitempty"`
	// IconURL - url of author icon (only supports http(s) and attachments)
	IconURL string `json:"icon_url,omitempty"`
	// ProxyIconURL - a proxied url of author icon
	ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

EmbedAuthor - represenst Embed Author Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure

type EmbedField

type EmbedField struct {
	// Name - name of the field (required)
	Name string `json:"name"`
	// Value - value of the field (required)
	Value string `json:"value"`
	// Inline - whether or not this field should display inline
	Inline bool `json:"inline,omitempty"`
}

EmbedField - used to represent an embed field object https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure

type EmbedFooter

type EmbedFooter struct {
	// Text - footer text (required)
	Text string `json:"text"`
	// IconURL - url of footer icon (only supports http(s) and attachments)
	IconURL string `json:"icon_url,omitempty"`
	// ProxyIconURL - a proxied url of footer icon
	ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

EmbedFooter represents Embed Footer Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure

type EmbedImage

type EmbedImage struct {
	// URl source url of image (only supports http(s) and attachments)
	URL string `json:"url,omitempty"`
	// ProxyURL - a proxied url of the image
	ProxyURL string `json:"proxy_url,omitempty"`
	// Height - height of image
	Height int `json:"height,omitempty"`
	// Width - width of image
	Width int `json:"width,omitempty"`
}

EmbedImage represents Embed Image Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure

type EmbedProvider

type EmbedProvider struct {
	// Name - name of provider
	Name string `json:"name,omitempty"`
	// URL - url of provider
	URL string `json:"url,omitempty"`
}

EmbedProvider represents Embed Provider Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure

type EmbedThumbnail

type EmbedThumbnail struct {
	// URL - source url of thumbnail (only supports http(s) and attachments)
	URL string `json:"url,omitempty"`
	// ProxyURL - a proxied url of the thumbnail
	ProxyURL string `json:"proxy_url,omitempty"`
	// Height - height of thumbnail
	Height int `json:"height,omitempty"`
	// Wifth - width of thumbnail
	Width int `json:"width,omitempty"`
}

EmbedThumbnail represents Embed Thumbnail Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure

type EmbedType

type EmbedType string

EmbedType - embed types are "loosely defined" and, for the most part, are not used by Discord's clients for rendering. Embed attributes power what is rendered. Embed types should be considered deprecated and might be removed in a future API version. https://discord.com/developers/docs/resources/channel#embed-object-embed-types

const (
	// EmbedTypeRich - generic embed rendered from embed attributes
	EmbedTypeRich EmbedType = "rich"
	// EmbedTypeImage - image embed
	EmbedTypeImage EmbedType = "image"
	// EmbedTypeVideo - video embed
	EmbedTypeVideo EmbedType = "video"
	// EmbedTypeGifv - animated gif image embed rendered as a video embed
	EmbedTypeGifv EmbedType = "gifv"
	// EmbedTypeArticle - article embed
	EmbedTypeArticle EmbedType = "article"
	// EmbedTypeLink - link embed
	EmbedTypeLink EmbedType = "link"
)

type EmbedVideo

type EmbedVideo struct {
	// URL - source url of video
	URL string `json:"url,omitempty"`
	// Height - height of video
	Height int `json:"height,omitempty"`
	// Width - width of video
	Width int `json:"width,omitempty"`
}

EmbedVideo represents Embed Video Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure

type Emoji

type Emoji struct {
	// ID (snowflake) - emoji id
	ID snowflake.Snowflake `json:"id"`
	// Name - emoji name (can be empty only in reaction emoji objects)
	Name string `json:"name"`
	// Roles - roles this emoji is whitelisted to
	Roles []*Role `json:"roles,omitempty"`
	// User - user that created this emoji
	User *User `json:"user,omitempty"`
	// RequireColons - whether this emoji must be wrapped in colons
	RequireColons bool `json:"require_colons,omitempty"`
	// Managed - whether this emoji is managed
	Managed bool `json:"managed,omitempty"`
	// Animated - whether this emoji is animated
	Animated bool `json:"animated,omitempty"`
	// Available - whether this emoji can be used, may be false due to loss of Server Boosts
	Available bool `json:"available,omitempty"`
}

Emoji represents Emoji Structure https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure

type GuildMember

type GuildMember struct {
	// User - the user this guild member represents
	User *User `json:"user,omitempty"`
	// Nick - this users guild nickname
	Nick string `json:"nick,omitempty"`
	// Roles - array of role object IDs (snowflakes)
	Roles []snowflake.Snowflake `json:"roles"`
	// JoindeAt - when the user joined the guild
	JoinedAt *time.Time `json:"joined_at"`
	// PremiumSince - when the user started boosting the guild
	PremiumSince *time.Time `json:"premium_since,omitempty"`
	// Deaf - whether the user is deafened in voice channels
	Deaf bool `json:"deaf"`
	// Mute - whether the user is muted in voice channels
	Mute bool `json:"mute"`
}

GuildMember represents Guild Member Structure https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure

type MentionType

type MentionType string

MentionType - discord mention type https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types

const (
	// MentionTypeRole can be used in AllowedMentions to allow mention roles
	MentionTypeRole MentionType = "roles"
	// MentionTypeUser can be used in AllowedMentions to allow mention users
	MentionTypeUser MentionType = "users"
	// MentionTypeEveryone can be used in AllowedMentions to allow mention @everyone
	MentionTypeEveryone MentionType = "everyone"
)

type Message

type Message struct {
	// ID (snowflake) - ID of the message
	ID snowflake.Snowflake `json:"id"`
	// ChannelID (snowflake) - ID of the channel the message was sent in
	ChannelID snowflake.Snowflake `json:"channel_id"`
	// GuildID (snowflake) - ID of the guild the message was sent in
	GuildID snowflake.Snowflake `json:"guild_id,omitempty"`
	// Author - the author of this message (not guaranteed to be a valid user, see below)
	Author *User `json:"author"`
	// Member - member properties for this message's author
	Member *GuildMember `json:"member,omitempty"`
	// Content - contents of the message
	Content string `json:"content"`
	// Timestamp - when this message was sent
	Timestamp *time.Time `json:"timestamp"`
	// EditedTimestamp - when this message was edited (or null if never)
	EditedTimestamp *time.Time `json:"edited_timestamp,omitempty"`
	// TTS - whether this was a TTS message
	TTS bool `json:"tts"`
	// MentionEveryone - whether this message mentions everyone
	MentionEveryone bool `json:"mention_everyone"`
	// Mentions - users specifically mentioned in the message
	Mentions []*User `json:"mentions"`
	// MentionRoles - specifically mentioned in this message
	MentionRoles []*Role `json:"mention_roles"`
	// MentionChannels - channels specifically mentioned in this message
	MentionChannels []*ChannelMention `json:"mention_channels,omitempty"`
	// Attachments - any attached files
	Attachments []*Attachment `json:"attachments"`
	// Embeds - any embedded content
	Embeds []*Embed `json:"embeds"`
	// Reaction - reactions to the message
	Reactions []*Reaction `json:"reactions,omitempty"`
	// Nonce - used for validating a message was sent
	Nonce string `json:"nonce,omitempty"`
	// Pinned - whether this message is pinned
	Pinned bool `json:"pinned"`
	// WebhookID (snowflake) - if the message is generated by a webhook, this is the webhook's ID
	WebhookID snowflake.Snowflake `json:"webhook_id,omitempty"`
	// Type - type of message
	Type int `json:"type"`
	// Activity - sent with Rich Presence-related chat embeds
	Activity *Activity `json:"activity,omitempty"`
	// Application sent with Rich Presence-related chat embeds
	Application *Application `json:"application,omitempty"`
	// MessageReference - reference data sent with crossposted messages
	MessageReference *MessageReference `json:"message_reference,omitempty"`
	// Flags - message flags `OR`d together, describes extra features of the message
	Flags MessageFlag `json:"flags,omitempty"`
}

Message represents a message sent in a channel within Discord. https://discord.com/developers/docs/resources/channel#message-object-message-structure

type MessageActivityType

type MessageActivityType int

MessageActivityType userd describes message activity types https://discord.com/developers/docs/resources/channel#message-object-message-activity-types

const (
	// MessageActivityTypeJoin - JOIN
	MessageActivityTypeJoin MessageActivityType = 1
	// MessageActivityTypeSpectate - SPECTATE
	MessageActivityTypeSpectate MessageActivityType = 2
	//MessageActivityTypeListen - LISTEN
	MessageActivityTypeListen MessageActivityType = 3
	// MessageActivityTypeJoinRequest - JOIN_REQUEST
	MessageActivityTypeJoinRequest MessageActivityType = 5
)

type MessageFlag

type MessageFlag int

MessageFlag used for describing extra features of the message by bits https://discord.com/developers/docs/resources/channel#message-object-message-flags

const (
	// MessageFlagsCrossposted - this message has been published to subscribed channels (via Channel Following)
	MessageFlagsCrossposted MessageFlag = 1 << 0
	// MessageFlagIsCrosspost - this message originated from a message in another channel (via Channel Following)
	MessageFlagIsCrosspost MessageFlag = 1 << 1
	// MessageFlagSupressEmbeds - do not include any embeds when serializing this message
	MessageFlagSupressEmbeds MessageFlag = 1 << 2
	// MessageFlagSourceMessageDeleted - the source message for this crosspost has been deleted (via Channel Following)
	MessageFlagSourceMessageDeleted MessageFlag = 1 << 3
	// MessageFlagUrgent - this message came from the urgent message system
	MessageFlagUrgent MessageFlag = 1 << 4
)

type MessageReference

type MessageReference struct {
	// MessageID (snowflake) - ID of the originating message
	MessageID snowflake.Snowflake `json:"name,omitempty"`
	// ChannelID (snowflake) - ID of the originating message's channel
	ChannelID snowflake.Snowflake `json:"channel_id"`
	// GuildID (snowflake) - ID of the originating message's guild
	GuildID snowflake.Snowflake `json:"guild_id,omitempty"`
}

MessageReference represents Message Reference Structure https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure

type Reaction

type Reaction struct {
	// Count - times this emoji has been used to react
	Count int `json:"count"`
	// Me - whether the current user reacted using this emoji
	Me bool `json:"me"`
	// Emoji - emoji information
	Emoji *Emoji `json:"emoji"`
}

Reaction represents Reaction Structure https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure

type Role

type Role struct {
	// ID (snowflake) - role ID
	ID snowflake.Snowflake `json:"id"`
	// Name - role name
	Name string `json:"name"`
	// COlor - integer representation of hexadecimal color code
	Color int `json:"color"`
	// Hoist - if this role is pinned in the user listing
	Hoist bool `json:"hoist"`
	// Position - position of this role
	Position int `json:"position"`
	// Permissions - permission bit set
	Permissions int `json:"permissions"`
	// Managed - whether this role is managed by an integration
	Managed bool `json:"managed"`
	// Mentionable - whether this role is mentionable
	Mentionable bool `json:"mentionable"`
}

Role - Roles represent a set of permissions attached to a group of users. Roles have unique names, colors, and can be "pinned" to the side bar, causing their members to be listed separately. Roles are unique per guild, and can have separate permission profiles for the global context (guild) and channel context. The @everyone role has the same ID as the guild it belongs to. https://discord.com/developers/docs/topics/permissions#role-object-role-structure

type User

type User struct {
	// ID (snowflake) - the user's id
	ID snowflake.Snowflake `json:"id"`
	// - the user's username, not unique across the platform
	Username string `json:"username"`
	// - the user's 4-digit discord-tag
	Discriminator string `json:"discriminator"`
	// - the user's avatar hash
	Avatar string `json:"avatar,omitempty"`
	// - whether the user belongs to an OAuth2 application
	Bot bool `json:"bot,omitempty"`
	// - whether the user is an Official Discord System user (part of the urgent message system)
	System bool `json:"system,omitempty"`
	// - whether the user has two factor enabled on their account
	MfaEnabled bool `json:"mfa_enabled,omitempty"`
	// - the user's chosen language option
	Locale string `json:"locale,omitempty"`
	// - whether the email on this account has been verified
	Verified bool `json:"verified,omitempty"`
	// - the user's email
	Email string `json:"email,omitempty"`
	// - the flags on a user's account
	Flags UserFlag `json:"flags,omitempty"`
	// - the type of Nitro subscription on a user's account
	PremiumType UserPremiumType `json:"premium_type,omitempty"`
	// - the public flags on a user's account
	PublicFlags UserFlag `json:"public_flags,omitempty"`
	// Member - user's member object
	Member *GuildMember `json:"member,omitempty"`
}

User represents User Structure https://discord.com/developers/docs/resources/user#user-object-user-structure

type UserFlag

type UserFlag int

UserFlag used to describe user's flags by bits https://discord.com/developers/docs/resources/user#user-object-user-flags

const (
	// UserFlagNone - None
	UserFlagNone UserFlag = 0
	// UserFlagDiscordEmployee - Discord Employee
	UserFlagDiscordEmployee UserFlag = 1 << 0
	// UserFlagDiscordPartner - Discord Partner
	UserFlagDiscordPartner UserFlag = 1 << 1
	// UserFlagHypeSquadEvents - HypeSquad Events
	UserFlagHypeSquadEvents UserFlag = 1 << 2
	// UserFlagBugHunterLevel1 - Bug Hunter Level 1
	UserFlagBugHunterLevel1 UserFlag = 1 << 3
	// UserFlagHouseBravery - House Bravery
	UserFlagHouseBravery UserFlag = 1 << 6
	// UserFlagHouseBrilliance - House Brilliance
	UserFlagHouseBrilliance UserFlag = 1 << 7
	// UserFlagHouseBalance - House Balance
	UserFlagHouseBalance UserFlag = 1 << 8
	// UserFlagEarlySupporter - Early Supporter
	UserFlagEarlySupporter UserFlag = 1 << 9
	// UserFlagTeamUser - Team User
	UserFlagTeamUser UserFlag = 1 << 10
	// UserFlagSystem - System
	UserFlagSystem UserFlag = 1 << 12
	// UserFlagBugHunterLevel2 - Bug Hunter Level 2
	UserFlagBugHunterLevel2 UserFlag = 1 << 14
	// UserFlagVerifiedBot - Verified Bot
	UserFlagVerifiedBot UserFlag = 1 << 16
	// UserFlagVerifiedBotDeveloper - Verified Bot Developer
	UserFlagVerifiedBotDeveloper UserFlag = 1 << 17
)

type UserPremiumType

type UserPremiumType int

UserPremiumType - premium types denote the level of premium a user has. https://discord.com/developers/docs/resources/user#user-object-premium-types

const (
	// UserPremiumTypeNone - None
	UserPremiumTypeNone UserPremiumType = 0
	// UserPremiumTypeNitroClassic - Nitro Classic
	UserPremiumTypeNitroClassic UserPremiumType = 1
	// UserPremiumTypeNitro - Nitro
	UserPremiumTypeNitro UserPremiumType = 2
)

type Webhook

type Webhook struct {
	// ID (snowflake) - the id of the webhook
	ID snowflake.Snowflake `json:"id"`
	// Type - the type of the webhook
	Type WebhookType `json:"type"`
	// GuildID (snowflake) - the guild id this webhook is for
	GuildID snowflake.Snowflake `json:"guild_id,omitempty"`
	// ChannelID (snowflake) - the channel id this webhook is for
	ChannelID snowflake.Snowflake `json:"channel_id"`
	// User - the user this webhook was created by (not returned when getting a webhook with its token)
	User *User `json:"user,omitempty"`
	// Name - the default name of the webhook
	Name string `json:"name,omitempty"`
	// Avatar - the default avatar of the webhook
	Avatar string `json:"avatar,omitempty"`
	// Token - the secure token of the webhook (returned for Incoming Webhooks)
	Token string `json:"token,omitempty"`
}

Webhook represents Webhook Structure https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-structure

type WebhookAPI

type WebhookAPI struct {
	// URL of webhook
	URL *url.URL
	// Client which will be used for http requests
	Client *http.Client
	// Wait - if `true`, then the response will be expected and parsed in `msg`.
	Wait bool
}

WebhookAPI - for those, who wants to use single webhook url several times

func NewWebhookAPI

func NewWebhookAPI(webhookID snowflake.Snowflake, webhookToken string, wait bool, client *http.Client) (*WebhookAPI, error)

NewWebhookAPI creates WebhookExecuter (https://discord.com/api/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN). if `wait` is `true`, then the response for method `Execute` will be expected and parsed in `msg`. client - *http.Client which will be used for http requests

func (*WebhookAPI) Delete

func (wa *WebhookAPI) Delete(ctx context.Context) error

Delete - deletes a webhook. Returns http status code, error

func (*WebhookAPI) Execute

func (wa *WebhookAPI) Execute(ctx context.Context, wep *WebhookExecuteParams, file io.Reader, filename string) (*Message, error)

Execute - executes webhook. If `wait` was set to `true`, then the response will be expected and parsed in `msg`. Return message, http status code, error

func (*WebhookAPI) Get

func (wa *WebhookAPI) Get(ctx context.Context) (*Webhook, error)

Get - gets information about webhook. Return webhook, http status code, error

func (*WebhookAPI) Modify

func (wa *WebhookAPI) Modify(ctx context.Context, wmp *WebhookModifyParams) (*Webhook, error)

Modify - modifies a webhook. Return webhook, http status code, error

type WebhookExecuteParams

type WebhookExecuteParams struct {
	// Content - the message contents (up to 2000 characters) [Required: one of content, file, embeds]
	Content string `json:"content,omitempty"`
	// Username - override the default username of the webhook [Required: false]
	Username string `json:"username,omitempty"`
	// AvatarURL - override the default avatar of the webhook [Required: false]
	AvatarURL string `json:"avatar_url,omitempty"`
	// TTS - true if this is a TTS message [Required: false]
	TTS bool `json:"tts,omitempty"`
	// Embeds - array of up to 10 embed objects [Required: one of content, file, embeds]
	Embeds []*Embed `json:"embeds,omitempty"`
	// AllowedMentions - allowed mentions for the message [Required: false]
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
}

WebhookExecuteParams represents webhook params payload structure https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params

type WebhookModifyParams

type WebhookModifyParams struct {
	// Name - the default name of the webhook
	Name string `json:"name,omitemprty"`
	// Avatar - image for the default webhook avatar
	// Look https://discord.com/developers/docs/reference#image-data
	Avatar string `json:"avatar,omitemprty"`
	// ChannelID - the new channel id this webhook should be moved to
	ChannelID snowflake.Snowflake `json:"channel_id,omitemprty"`
}

WebhookModifyParams represents modify params for webhook api https://discord.com/developers/docs/resources/webhook#modify-webhook-json-params

type WebhookType

type WebhookType int

WebhookType used for describing webhook types https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types

const (
	// WebhookTypeIncoming - incoming Webhooks can post messages to channels with a generated token
	WebhookTypeIncoming WebhookType = 1
	// WebhookTypeChannelFollower - channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels
	WebhookTypeChannelFollower WebhookType = 2
)

Jump to

Keyboard shortcuts

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