# README
DiscordHook
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)
}
}
# Functions
NewWebhookAPI creates WebhookExecuter (https://discord.com/api/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN).
# Constants
ChannelTypeChannelTypeGuildText - a text channel within a server.
ChannelTypeDM - a direct message between users.
ChannelTypeGroupDM - a direct message between multiple users.
ChannelTypeGuildCATEGORY - an organizational category that contains up to 50 channels.
ChannelTypeGuildNews - a channel that users can follow and crosspost into their own server.
ChannelTypeGuildSstor - a channel in which game developers can sell their game on Discord.
ChannelTypeGuildVoice - a voice channel within a server.
EmbedTypeArticle - article embed.
EmbedTypeGifv - animated gif image embed rendered as a video embed.
EmbedTypeImage - image embed.
EmbedTypeLink - link embed.
EmbedTypeRich - generic embed rendered from embed attributes.
EmbedTypeVideo - video embed.
MentionTypeEveryone can be used in AllowedMentions to allow mention @everyone.
MentionTypeRole can be used in AllowedMentions to allow mention roles.
MentionTypeUser can be used in AllowedMentions to allow mention users.
MessageActivityTypeJoin - JOIN.
MessageActivityTypeJoinRequest - JOIN_REQUEST.
MessageActivityTypeListen - LISTEN.
MessageActivityTypeSpectate - SPECTATE.
MessageFlagIsCrosspost - this message originated from a message in another channel (via Channel Following).
MessageFlagsCrossposted - this message has been published to subscribed channels (via Channel Following).
MessageFlagSourceMessageDeleted - the source message for this crosspost has been deleted (via Channel Following).
MessageFlagSupressEmbeds - do not include any embeds when serializing this message.
MessageFlagUrgent - this message came from the urgent message system.
UserFlagBugHunterLevel1 - Bug Hunter Level 1.
UserFlagBugHunterLevel2 - Bug Hunter Level 2.
UserFlagDiscordEmployee - Discord Employee.
UserFlagDiscordPartner - Discord Partner.
UserFlagEarlySupporter - Early Supporter.
UserFlagHouseBalance - House Balance.
UserFlagHouseBravery - House Bravery.
UserFlagHouseBrilliance - House Brilliance.
UserFlagHypeSquadEvents - HypeSquad Events.
UserFlagNone - None.
UserFlagSystem - System.
UserFlagTeamUser - Team User.
UserFlagVerifiedBot - Verified Bot.
UserFlagVerifiedBotDeveloper - Verified Bot Developer.
UserPremiumTypeNitro - Nitro.
UserPremiumTypeNitroClassic - Nitro Classic.
UserPremiumTypeNone - None.
WebhookTypeChannelFollower - channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels.
WebhookTypeIncoming - incoming Webhooks can post messages to channels with a generated token.
# Structs
Activity represents Message Activity Structure https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure.
AllowedMentions allows for more granular control over mentions without various hacks to the message content.
Application represents Message Application Structure https://discord.com/developers/docs/resources/channel#message-object-message-application-structure.
Attachment represents Attachment Structure https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure.
ChannelMention represents Channel Mention Structure https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure.
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.
EmbedAuthor - represenst Embed Author Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure.
EmbedField - used to represent an embed field object https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure.
EmbedFooter represents Embed Footer Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure.
EmbedImage represents Embed Image Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure.
EmbedProvider represents Embed Provider Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure.
EmbedThumbnail represents Embed Thumbnail Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure.
EmbedVideo represents Embed Video Structure https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure.
Emoji represents Emoji Structure https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure.
GuildMember represents Guild Member Structure https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure.
Message represents a message sent in a channel within Discord.
MessageReference represents Message Reference Structure https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure.
Reaction represents Reaction Structure https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure.
Role - Roles represent a set of permissions attached to a group of users.
User represents User Structure https://discord.com/developers/docs/resources/user#user-object-user-structure.
Webhook represents Webhook Structure https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-structure.
WebhookAPI - for those, who wants to use single webhook url several times.
WebhookExecuteParams represents webhook params payload structure https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params.
WebhookModifyParams represents modify params for webhook api https://discord.com/developers/docs/resources/webhook#modify-webhook-json-params.
# Type aliases
ChannelType - channel type integer https://discord.com/developers/docs/resources/channel#channel-object-channel-types.
EmbedType - embed types are "loosely defined" and, for the most part, are not used by Discord's clients for rendering.
MentionType - discord mention type https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types.
MessageActivityType userd describes message activity types https://discord.com/developers/docs/resources/channel#message-object-message-activity-types.
MessageFlag used for describing extra features of the message by bits https://discord.com/developers/docs/resources/channel#message-object-message-flags.
UserFlag used to describe user's flags by bits https://discord.com/developers/docs/resources/user#user-object-user-flags.
UserPremiumType - premium types denote the level of premium a user has.
WebhookType used for describing webhook types https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types.