guildedgo

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 13 Imported by: 2

README

guildedgo

A guilded.gg library in Go

Getting started

go get github.com/itschip/guildedgo

Examples

Listen to events
package main

import (
        "fmt"

        "github.com/itschip/guildedgo"
)

func main() {
        guildedClient := guildedgo.NewClient(&guildedgo.Config{
                Token:    "YOUR_TOKEN",
                ServerID: "YOUR_SERVER_ID",
        })

        // Listen to the ChatMessageCreated event
        guildedClient.On("ChatMessageCreated", func(client *guildedgo.Client, v any) {
                data, ok := v.(*guildedgo.ChatMessageCreated)

                if ok {
                        fmt.Println(data.Message.Content)

                        if data.Message.Content == "!ping" {
                                guildedClient.Channel.SendMessage(data.Message.ChannelID, &guildedgo.MessageObject{
                                        Content: "pong!",
                                })
                        }

                }
        })

        // Open socket
        guildedClient.Open()
}
Command builder
serverID := internal.GetEnv("SERVER_ID")
	token := internal.GetEnv("TOKEN")

	config := &guildedgo.Config{
		ServerID: serverID,
		Token:    token,
	}

	c := guildedgo.NewClient(config)

	commands := &guildedgo.CommandsBuilder{
		Commands: []Command{
			{
				CommandName: "!test",
				Action: func(client *Client, v *ChatMessageCreated) {
					client.Channel.SendMessage(v.Message.ChannelID, &MessageObject{
						Content: "Test",
					})

					fmt.Println("Test working")
				},
			},
			{
				CommandName: "!party",
				Action: func(client *Client, v *ChatMessageCreated) {
					client.Channel.SendMessage(v.Message.ChannelID, &MessageObject{
						Content: "Yeah!!! Let's party",
					})

					fmt.Println("Party working")
				},
			},
		},
	}

	c.CommandService.AddCommands(commands)

	c.Open()

Documentation

Index

Constants

View Source
const (
	ChannelTypeAnnouncements string = "announcements"
	ChannelTypeChat          string = "chat"
	ChannelTypeCalendar      string = "calendar"
	ChannelTypeForums        string = "forums"
	ChannelTypeMedia         string = "media"
	ChannelTypeDocs          string = "docs"
	ChannelTypeVoice         string = "voice"
	ChannelTypeList          string = "list"
	ChannelTypeScheduling    string = "scheduling"
	ChannelTypeStream        string = "stream"
)
View Source
const (
	ChatMessageTypeDefault string = "default"
	ChatMessageTypeSystem  string = "system"
)
View Source
const (
	ServerTypeTeam         string = "team"
	ServerTypeOrganization string = "organization"
	ServerTypeCommunity    string = "community"
	ServerTypeClan         string = "clan"
	ServerTypeGuild        string = "guild"
	ServerTypeFriends      string = "friends"
	ServerTypeStreaming    string = "streaming"
	ServerTypeOther        string = "other"
)
View Source
const (
	UserTypeUser = "user"
	UserTypeBot  = "bot"
)

Variables

This section is empty.

Functions

func DoRequest added in v0.1.4

func DoRequest(method string, endpoint string, body []byte, token string) ([]byte, error)

Types

type AllMessagesResponse

type AllMessagesResponse struct {
	Messages []ChatMessage `json:"messages"`
}

type AnncounmentResponse added in v0.5.2

type AnncounmentResponse struct {
	Announcement `json:"announcement"`
}

type Announcement added in v0.5.2

type Announcement struct {
	ID        string   `json:"id"`
	ServerID  string   `json:"serverId"`
	ChannelID string   `json:"channelId"`
	CreatedAt string   `json:"createdAt"`
	CreatedBy string   `json:"createdBy"`
	Content   string   `json:"content"`
	Mentions  Mentions `json:"mentions,omitempty"`
	Title     string   `json:"title"`
}

type AnnouncementService added in v0.5.2

type AnnouncementService interface {
	CreateAnnouncement(serverID string, channelID string, title string, content string) (*Announcement, error)
	GetAnnouncements(channelID string, query *GetAnnouncementParams) ([]Announcement, error)
	ReadAnnouncement(channelID string, announcementID string) (*Announcement, error)
	UpdateAnnouncement(channelID string, announcementID string, title string, content string) (*Announcement, error)
	DeleteAnnouncement(channelID string, announcementID string) error
}

type AwardXPResponse added in v0.4.0

type AwardXPResponse struct {
	Total int `json:"total"`
}

type BotServerMembershipCreated added in v0.1.4

type BotServerMembershipCreated struct {
	Server `json:"server"`

	// The ID of the user who created this server membership
	CreatedBy string `json:"createdBy"`
}

type BotServerMembershipDeleted added in v0.1.4

type BotServerMembershipDeleted struct {
	Server `json:"server"`

	// The ID of the user who deleted this server membership
	CreatedBy string `json:"createdBy"`
}

type CalendarEvent added in v0.2.0

type CalendarEvent struct {
	ID           int    `json:"id"`
	ServerID     string `json:"serverId"`
	ChannelID    string `json:"channelId"`
	Name         string `json:"name"`
	Description  string `json:"description,omitempty"`
	Location     string `json:"location,omitempty"`
	URL          string `json:"url,omitempty"`
	Color        int    `json:"color,omitempty"`
	RSVPLimit    int    `json:"rsvpLimit,omitempty"`
	StartsAt     string `json:"startsAt"`
	Duration     int    `json:"duration,omitempty"`
	IsPrivate    bool   `json:"isPrivate,omitempty"`
	Mentions     `json:"mentions,omitempty"`
	CreatedAt    string `json:"createdAt"`
	CreatedBy    string `json:"createdBy"`
	Cancellation struct {
		Description string `json:"description,omitempty"`
		CreatedBy   string `json:"createdBy,omitempty"`
	} `json:"cancellation,omitempty"`
}

type CalendarEventCreated added in v0.2.0

type CalendarEventCreated struct {
	ServerID      string `json:"serverId"`
	CalendarEvent `json:"calendarEvent"`
}

type CalendarEventDeleted added in v0.2.0

type CalendarEventDeleted struct {
	ServerID      string `json:"serverId"`
	CalendarEvent `json:"calendarEvent"`
}

type CalendarEventResponse added in v0.2.0

type CalendarEventResponse struct {
	Event CalendarEvent `json:"calendarEvent"`
}

type CalendarEventRsvp added in v0.2.0

type CalendarEventRsvp struct {
	CalendarEventID int    `json:"calendarEventId"`
	ChannelID       string `json:"channelId"`
	ServerID        string `json:"serverId"`
	UserID          string `json:"userId"`
	Status          string `json:"status"`
	CreatedBy       string `json:"createdBy"`
	CreatedAt       string `json:"createdAt"`
	UpdatedBy       string `json:"updatedBy"`
	UpdatedAt       string `json:"updatedAt"`
}

type CalendarEventRsvpResponse added in v0.2.1

type CalendarEventRsvpResponse struct {
	Rsvp CalendarEventRsvp `json:"calendarEventRsvp"`
}

type CalendarEventRsvpsResponse added in v0.2.1

type CalendarEventRsvpsResponse struct {
	Rsvps []CalendarEventRsvp `json:"calendarEventRsvps"`
}

type CalendarEventUpdated added in v0.2.0

type CalendarEventUpdated struct {
	ServerID      string `json:"serverId"`
	CalendarEvent `json:"calendarEvent"`
}

type CalendarEventsResponse added in v0.2.0

type CalendarEventsResponse struct {
	Events []CalendarEvent `json:"calendarEvents"`
}

type CalendarService added in v0.2.0

type CalendarService interface {
	CreateEvent(channelId string, event *CalenderEventObject) (*CalendarEvent, error)
	GetEvents(channelId string, options *GetEventsOptions) ([]CalendarEvent, error)
	GetEvent(channelId string, eventId int) (*CalendarEvent, error)
	UpdateEvent(channelId string, eventId int, event *CalenderEventObject) (*CalendarEvent, error)
	DeleteEvent(channelId string, eventId int) error
	GetEventRSVP(channelId string, eventId int, userId string) (*CalendarEventRsvp, error)
	CreateOrUpdateEventRSVP(channelId string, eventId int, userId string) (*CalendarEventRsvp, error)
	DeleteEventRSVP(channelId string, eventId int, userId string) error
	GetEventRSVPs(channelId string, eventId int) ([]CalendarEventRsvp, error)
}

type CalenderEventObject added in v0.2.1

type CalenderEventObject struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Location    string `json:"location,omitempty"`
	StartsAt    string `json:"startsAt,omitempty"`
	URL         string `json:"url,omitempty"`
	Color       int    `json:"color,omitempty"`
	RSVPLimit   int    `json:"rsvpLimit,omitempty"`
	Duration    int    `json:"duration,omitempty"`
	IsPrivate   bool   `json:"isPrivate,omitempty"`
}

type Category added in v1.1.0

type Category struct {
	ID        int    `json:"id"`
	ServerID  string `json:"serverId"`
	GroupID   string `json:"groupId"`
	CreatedAt string `json:"createdAt"`
	UpdatedAt string `json:"updatedAt"`
	Name      string `json:"name"`
}

type CategoryService added in v1.1.0

type CategoryService interface {
	Read(categoryID int) (*Category, error)
	Create(options *CreateCategory) (*Category, error)
	Update(categoryID int, name string) (*Category, error)
	Delete(categoryID int) error
}

type ChannelArchived added in v1.0.0

type ChannelArchived struct {
	ServerID string        `json:"serverId"`
	Channel  ServerChannel `json:"channel"`
}

type ChannelRestored added in v1.0.0

type ChannelRestored struct {
	ServerID string        `json:"serverId"`
	Channel  ServerChannel `json:"channel"`
}

type ChannelService

type ChannelService interface {
	CreateChannel(channelObject *NewChannelObject) (*ServerChannel, error)
	GetChannel(channelId string) (*ServerChannel, error)
	UpdateChannel(channelId string, channelObject *UpdateChannelObject) (*ServerChannel, error)
	DeleteChannel(channelId string) error
	SendMessage(channelId string, message *MessageObject) (*ChatMessage, error)
	GetMessages(channelId string, getObject *GetMessagesObject) (*[]ChatMessage, error)
	GetMessage(channelId string, messageId string) (*ChatMessage, error)
	UpdateChannelMessage(channelId string, messageId string, newMessage *MessageObject) (*ChatMessage, error)
	DeleteChannelMessage(channelId string, messageId string) error
}

type ChatEmbed added in v0.1.4

type ChatEmbed struct {
	// Main header of the embed (max length 256)
	Title string `json:"embed,omitempty"`

	// Subtext of the embed (max length 2048)
	Description string `json:"description,omitempty"`

	// URL to linkify the title field with (max length 1024; regex ^(?!attachment))
	URL string `json:"url,omitempty"`

	// Decimal value of the color that the left border should be (min 0; max 16777215)
	Color int `json:"color,omitempty"`

	// A small section at the bottom of the embed
	Footer ChatEmbedFooter `json:"footer,omitempty"`

	// A timestamp to put in the footer
	Timestamp string `json:"timestamp,omitempty"`

	// An image to the right of the embed's content
	Thumbnail ChatEmbedThumbnail `json:"thumbnail,omitempty"`

	// The main picture to associate with the embed
	Image ChatEmbedImage `json:"image"`

	// A small section above the title of the embed
	Author ChatEmbedAuthor `json:"author,omitempty"`

	// Table-like cells to add to the embed (max items 25)
	Fields []ChatEmbedField `json:"fields,omitempty"`
}

ChatEmbed are rich content sections optionally associated with chat messages. Properties with "webhook-markdown" support allow for the following: link, italic, bold, strikethrough, underline, inline code, block code, reaction, and mention.

type ChatEmbedAuthor added in v0.1.4

type ChatEmbedAuthor struct {
	// Name of the author (max length 256)
	Name string `jsojn:"name,omitempty"`

	// URL to linkify the author's name field (max length 1024; regex ^(?!attachment))
	URL string `json:"url,omitempty"`

	// URL of a small image to display to the left of the author's name (max length 1024
	IconURL string `json:"icon_url,omitempty"`
}

type ChatEmbedField added in v0.1.4

type ChatEmbedField struct {
	// Header of the table-like cell (max length 256)
	Name string `json:"name"`

	// Subtext of the table-like cell (max length 1024)
	Value string `json:"value"`

	// If the field should wrap or not (default false)
	Inline bool `json:"inline,omitempty"`
}

type ChatEmbedFooter added in v0.1.4

type ChatEmbedFooter struct {
	// URL of a small image to put in the footer (max length 1024)
	IconURL string `json:"icon_url,omitempty"`

	// Text of the footer (max length 2048)
	Text string `json:"text"`
}

type ChatEmbedImage added in v0.1.4

type ChatEmbedImage struct {
	// URL of the image (max length 1024)
	URL string `json:"url,omitempty"`
}

type ChatEmbedThumbnail added in v0.1.4

type ChatEmbedThumbnail struct {
	// URL of the image (max length 1024)
	URL string `json:"url,omitempty"`
}

type ChatMessage

type ChatMessage struct {
	// The ID of the message
	ID string `json:"id"`

	// The type of chat message.
	// "system" messages are generated by Guilded, while "default" messages are user or bot-generated.
	Type string `json:"type,omitempty"`

	// The ID of the server
	ServerID string `json:"serverId,omitempty"`
	GroupID  string `json:"groupId,omitempty"`

	// The ID of the channel
	ChannelID string `json:"channelId"`

	// The content of the message
	Content string `json:"content,omitempty"`

	// Embeds for the message.
	//
	// (min items 1; max items 10
	Embeds []ChatEmbed `json:"embeds,omitempty"`

	// Message IDs that were replied to
	ReplyMessageIds []string `json:"replyMessageIds,omitempty"`

	// If set, this message will only be seen by those mentioned or replied to.
	IsPrivate bool `json:"isPrivate,omitempty"`

	// If set, this message did not notify mention or reply recipients (default false)
	IsSilent bool `json:"isSilent,omitempty"`

	Mentions `json:"mentions,omitempty"`

	// The ISO 8601 timestamp that the message was created at.
	CreatedAt string `json:"createdAt"`

	// The ID for the user who created this messsage
	// (Note: if this event has `createdByWebhookId` present,
	// this field will still be populated, but can be ignored.
	// In this case, the value of this field will always be Ann6LewA)
	CreatedBy string `json:"createdBy"`

	// The ID of the webhook who created this message, if was created by a webhook
	CreatedByWebhookId string `json:"createdByWebhookId,omitempty"`

	// The IOSO 8601 timestamp that the message was updated at, if relevant
	UpdatedAt string `json:"updatedAt,omitempty"`
}

ChatMessage is the default message struct

type ChatMessageCreated added in v0.1.2

type ChatMessageCreated struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	Message ChatMessage `json:"message"`
}

type ChatMessageDeleted added in v0.1.4

type ChatMessageDeleted struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	Message struct {
		// The ID of the message
		ID string `json:"id"`

		// The ID of the serve
		ServerID string `json:"serverId,omitempty"`

		// The ID of the channel
		ChannelID string `json:"channelId"`

		DeletedAt string `json:"deletedAt"`

		IsPrivate bool `json:"isPrivate,omitempty"`
	} `json:"message"`
}

type ChatMessageUpdated added in v0.1.4

type ChatMessageUpdated struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	Message ChatMessage `json:"message"`
}

type Client

type Client struct {
	sync.RWMutex

	Token    string
	ServerID string

	Channel        ChannelService
	Members        MembersService
	Roles          RoleService
	Server         ServerService
	Forums         ForumService
	Calendar       CalendarService
	Reactions      ReactionService
	List           ListService
	Webhooks       WebhookService
	ServerXP       ServerXPService
	CommandService CommandService
	DocComments    DocCommentService
	Docs           DocsService
	Socials        SocialsService
	Announcements  AnnouncementService
	Category       CategoryService
	Users          UserService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *Config) *Client

func (*Client) Close added in v0.5.5

func (c *Client) Close()

func (*Client) Command added in v0.1.3

func (c *Client) Command(cmd string, callback func(client *Client, v *ChatMessageCreated))

Command listens to ChatMessageCreated and fires a func when the message content matches the command

func (*Client) DeleteRequest

func (c *Client) DeleteRequest(endpoint string) ([]byte, error)

func (*Client) GetRequest

func (c *Client) GetRequest(endpoint string) ([]byte, error)

func (*Client) GetRequestV2 added in v0.1.3

func (c *Client) GetRequestV2(endpoint string, v any) error

func (*Client) On added in v0.1.3

func (c *Client) On(event string, callback func(client *Client, v any))

On listens to any event

func (*Client) Open added in v0.1.1

func (c *Client) Open()

func (*Client) PatchRequest added in v0.1.4

func (c *Client) PatchRequest(endpoint string, body any, v any) error

func (*Client) PostRequest

func (c *Client) PostRequest(endpoint string, body interface{}) ([]byte, error)

func (*Client) PostRequestV2 added in v0.1.4

func (c *Client) PostRequestV2(endpoint string, body any, v any) error

func (*Client) PutRequest

func (c *Client) PutRequest(endpoint string, body interface{}) ([]byte, error)

func (*Client) PutRequestV2 added in v0.3.0

func (c *Client) PutRequestV2(endpoint string, body interface{}, v any) error

type Command added in v0.4.1

type Command struct {
	CommandName string
	Action      func(client *Client, v *ChatMessageCreated)
}

type CommandService added in v0.4.1

type CommandService interface {
	AddCommand(command *Command)
	AddCommands(commands *CommandsBuilder)
}

type CommandsBuilder added in v0.4.1

type CommandsBuilder struct {
	Commands []Command
}

type Config

type Config struct {
	Token    string
	ServerID string
}

type CreateCategory added in v1.1.0

type CreateCategory struct {
	Name    string `json:"name"`
	GroupID string `json:"groupId,omitempty"`
}

type Doc added in v0.2.0

type Doc struct {
	ID        int    `json:"id"`
	ServerID  string `json:"serverId"`
	ChannelID string `json:"channelId"`
	Title     string `json:"title"`
	Content   string `json:"content"`
	Mentions  `json:"mentions,omitempty"`
	CreatedAt string `json:"createdAt"`
	CreatedBy string `json:"createdBy"`
	UpdatedAt string `json:"updatedAt,omitempty"`
	UpdatedBy string `json:"updatedBy,omitempty"`
}

type DocComment added in v0.4.1

type DocComment struct {
	ID        int    `json:"id"`
	Content   string `json:"content"`
	CreatedAt string `json:"createdAt"`
	CreatedBy string `json:"createdBy"`
	UpdatedAt string `json:"updatedAt,omitempty"`
	ChannelID string `json:"channelId"`
	DocID     int    `json:"docId"`
	Mentions  `json:"mentions,omitempty"`
}

type DocCommentService added in v0.4.3

type DocCommentService interface {
	Create(channelID string, docID int, content string) (*DocComment, error)
	GetComments(channelID string, docID int) ([]DocComment, error)
	GetDocComment(channelID string, docID int, commentID int) (*DocComment, error)
	UpdateDocComment(channelID string, docID int, commentID int, content string) (*DocComment, error)
	DeleteDocComment(channelID string, docID int, commentID int) error
}

type DocCreated added in v0.2.0

type DocCreated struct {
	ServerID string `json:"serverId"`
	Doc      `json:"doc"`
}

type DocDeleted added in v0.2.0

type DocDeleted struct {
	ServerID string `json:"serverId"`
	Doc      `json:"doc"`
}

type DocObject added in v0.3.0

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

type DocResponse added in v0.3.0

type DocResponse struct {
	Doc `json:"doc"`
}

type DocUpdated added in v0.2.0

type DocUpdated struct {
	ServerID string `json:"serverId"`
	Doc      `json:"doc"`
}

type DocsResponse added in v0.3.0

type DocsResponse struct {
	Docs []Doc `json:"docs"`
}

type DocsService added in v0.3.0

type DocsService interface {
	Create(channelId string) (*Doc, error)
}

type Emote added in v0.2.0

type Emote struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

type Event added in v0.1.2

type Event struct {
	Callback func(*Client, any)
	Type     *interface{}
}

type ForumCommentObject added in v0.2.0

type ForumCommentObject struct {
	Content string `json:"content"`
}

type ForumService added in v0.2.0

type ForumService interface {
	CreateForumTopic(channelId string, forumTopicObject *ForumTopicObject) (*ForumTopic, error)
	GetForumTopics(channelId string) (*[]ForumTopicSummary, error)
	GetForumTopic(channelId string, forumTopicId int) (*ForumTopic, error)
	UpdateForumTopic(channelId string, forumTopicId int, updateTopicObject *UpdateTopicObject) (*ForumTopic, error)
	DeleteForumTopic(channelId string, forumTopicId int) error
	PinForumTopic(channelId string, forumTopicId int) error
	UnpinForumTopic(channelId string, forumTopicId int) error
	LockForumTopic(channelId string, forumTopicId int) error
	UnlockForumTopic(channelId string, forumTopicId int) error
	CreateTopicComment(channelId string, forumTopicId int, forumCommentObject *ForumCommentObject) (*ForumTopicComment, error)
}

type ForumTopic added in v0.1.4

type ForumTopic struct {
	// The ID of the forum topic
	ID int `json:"id"`

	// The ID of the server
	ServerID string `json:"serverId"`

	// The ID of the channel
	ChannelID string `json:"channelId"`

	// The title of the forum topic (min length 1; max length 500)
	Title string `json:"title"`

	// The ISO 8601 timestamp that the forum topic was created at
	CreatedAt string `json:"createdAt"`

	// The ID of the user who created this forum topic
	// (Note: If this event has createdByWebhookId present, this field will still be populated,
	// but can be ignored. In this case, the value of this field will always be Ann6LewA)
	CreatedBy string `json:"createdBy"`

	// The ID of the webhook who created this forum topic, if it was created by a webhook
	CreatedByWebhookID string `json:"createdByWebhookId,omitempty"`

	// The ISO 8601 timestamp that the forum topic was updated at, if relevant
	UpdatedAt string `json:"updatedAt,omitempty"`

	// The ISO 8601 timestamp that the forum topic was bumped at.
	// This timestamp is updated whenever there is any activity on the posts within the forum topic.
	BumpedAt string `json:"bumpedAt,omitempty"`

	// (default false)
	IsPinned bool `json:"isPinned,omitempty"`

	// (default false)
	IsLocked bool `json:"isLocked,omitempty"`

	// The content of the forum topic
	Content string `json:"content"`

	Mentions `json:"mentions,omitempty"`
}

type ForumTopicComment added in v0.2.0

type ForumTopicComment struct {
	ID           int    `json:"id"`
	Content      string `json:"content"`
	CreatedAt    string `json:"createdAt"`
	UpdatedAt    string `json:"updatedAt"`
	ChannelID    string `json:"channelId"`
	ForumTopicID int    `json:"forumTopicId"`
	CreatedBy    string `json:"createdBy"`
	Mentions     `json:"mentions"`
}

type ForumTopicCommentCreated added in v0.2.0

type ForumTopicCommentCreated struct {
	ServerID          string `json:"serverId"`
	ForumTopicComment `json:"forumTopicComment"`
}

type ForumTopicCommentDeleted added in v0.2.0

type ForumTopicCommentDeleted struct {
	ServerID          string `json:"serverId"`
	ForumTopicComment `json:"forumTopicComment"`
}

type ForumTopicCommentUpdated added in v0.2.0

type ForumTopicCommentUpdated struct {
	ServerID          string `json:"serverId"`
	ForumTopicComment `json:"forumTopicComment"`
}

type ForumTopicCreated added in v0.2.0

type ForumTopicCreated struct {
	ServerID   string `json:"serverId"`
	ForumTopic `json:"forumTopic"`
}

type ForumTopicDeleted added in v0.2.0

type ForumTopicDeleted struct {
	ServerID   string `json:"serverId"`
	ForumTopic `json:"forumTopic"`
}

type ForumTopicLocked added in v0.2.0

type ForumTopicLocked struct {
	ServerID   string `json:"serverId"`
	ForumTopic `json:"forumTopic"`
}

type ForumTopicObject added in v0.2.0

type ForumTopicObject struct {
	Title   string `json:"title"`
	Content string `json:"content"`
}

type ForumTopicPinned added in v0.2.0

type ForumTopicPinned struct {
	ServerID   string `json:"serverId"`
	ForumTopic `json:"forumTopic"`
}

type ForumTopicReactionCreated added in v0.2.0

type ForumTopicReactionCreated struct {
	ServerID string `json:"serverId"`
	Reaction struct {
		ChannelID    string `json:"channelId"`
		CreatedBy    string `json:"createdBy"`
		Emote        `json:"emote"`
		ForumTopicID int `json:"forumTopicId"`
	}
}

type ForumTopicReactionDeleted added in v0.2.0

type ForumTopicReactionDeleted struct {
	ServerID string `json:"serverId"`
	Reaction struct {
		ChannelID    string `json:"channelId"`
		CreatedBy    string `json:"createdBy"`
		Emote        `json:"emote"`
		ForumTopicID int `json:"forumTopicId"`
	}
}

type ForumTopicSummary added in v0.1.4

type ForumTopicSummary struct {
	// The ID of the forum topic
	ID int `json:"id"`

	// The ID of the server
	ServerID string `json:"serverId"`

	// The ID of the channel
	ChannelID string `json:"channelId"`

	// The title of the forum topic (min length 1; max length 500)
	Title string `json:"title"`

	// The ISO 8601 timestamp that the forum topic was created at
	CreatedAt string `json:"createdAt"`

	// The ID of the user who created this forum topic
	// (Note: If this event has createdByWebhookId present, this field will still be populated,
	// but can be ignored. In this case, the value of this field will always be Ann6LewA)
	CreatedBy string `json:"createdBy"`

	// The ID of the webhook who created this forum topic, if it was created by a webhook
	CreatedByWebhookID string `json:"createdByWebhookId,omitempty"`

	// The ISO 8601 timestamp that the forum topic was updated at, if relevant
	UpdatedAt string `json:"updatedAt,omitempty"`

	// The ISO 8601 timestamp that the forum topic was bumped at.
	// This timestamp is updated whenever there is any activity on the posts within the forum topic.
	BumpedAt string `json:"bumpedAt,omitempty"`

	// (default false)
	IsPinned bool `json:"isPinned,omitempty"`

	// (default false)
	IsLocked bool `json:"isLocked,omitempty"`
}

type ForumTopicUnlocked added in v0.2.0

type ForumTopicUnlocked struct {
	ServerID   string `json:"serverId"`
	ForumTopic `json:"forumTopic"`
}

type ForumTopicUnpinned added in v0.2.0

type ForumTopicUnpinned struct {
	ServerID   string `json:"serverId"`
	ForumTopic `json:"forumTopic"`
}

type ForumTopicUpdated added in v0.2.0

type ForumTopicUpdated struct {
	ServerID   string `json:"serverId"`
	ForumTopic `json:"forumTopic"`
}

type GetAnnouncementParams added in v0.5.2

type GetAnnouncementParams struct {
	Before string
	Limit  int
}

type GetEventsOptions added in v0.2.0

type GetEventsOptions struct {
	Before string
	After  string
	Limit  int
}

type GetMessageResponse

type GetMessageResponse struct {
	Message ChatMessage `json:"message"`
}

type GetMessagesObject

type GetMessagesObject struct {
	Before         string `json:"before"`
	After          string `json:"after"`
	Limit          int    `json:"limit"`
	IncludePrivate bool   `json:"includePrivate"`
}

type ListItem added in v0.3.0

type ListItem struct {
	ID                 string `json:"id"`
	ServerID           string `json:"serverId"`
	ChannelID          string `json:"channelId"`
	Messsage           string `json:"message"`
	Mentions           `json:"mentions,omitempty"`
	CreatedAt          string `json:"createdAt"`
	CreatedBy          string `json:"createdBy"`
	CreatedByWebhookID string `json:"createdByWebhookId,omitempty"`
	UpdatedAt          string `json:"updatedAt",omitempty`
	UpdatedBy          string `json:"updatedBy,omitempty"`
	ParentListItemID   string `json:"parentListItemId,omitempty"`
	CompletedAt        string `json:"completedAt,omitempty"`
	CompletedBy        string `json:"completedBy,omitempty"`
	Note               struct {
		CreatedAt string `json:"createdAt"`
		CreatedBy string `json:"createdBy"`
		UpdatedAt string `json:"updatedAt,omitempty"`
		UpdatedBy string `json:"updatedBy"`
		Mentions  `json:"mentions,omitempty"`
		Content   string `json:"content"`
	} `json:"note"`
}

type ListItemSummary added in v0.3.0

type ListItemSummary struct {
	ID                 string `json:"id"`
	ServerID           string `json:"serverId"`
	ChannelID          string `json:"channelId"`
	Messsage           string `json:"message"`
	Mentions           `json:"mentions,omitempty"`
	CreatedAt          string `json:"createdAt"`
	CreatedBy          string `json:"createdBy"`
	CreatedByWebhookID string `json:"createdByWebhookId,omitempty"`
	UpdatedAt          string `json:"updatedAt,omitempty"`
	UpdatedBy          string `json:"updatedBy,omitempty"`
	ParentListItemID   string `json:"parentListItemId,omitempty"`
	CompletedAt        string `json:"completedAt,omitempty"`
	CompletedBy        string `json:"completedBy,omitempty"`
	Note               struct {
		CreatedAt string `json:"createdAt"`
		CreatedBy string `json:"createdBy"`
		UpdatedAt string `json:"updatedAt,omitempty"`
		UpdatedBy string `json:"updatedBy"`
	} `json:"note,omitempty"`
}

type ListObject added in v0.3.0

type ListObject struct {
	Message string `json:"message"`
	Note    struct {
		Content string `json:"content"`
	} `json:"note"`
}

type ListService added in v0.3.0

type ListService interface {
	CreateListItem(channelID string, listObject ListObject) (*ListItem, error)
	GetChannelListItems(channelID string) ([]ListItemSummary, error)
	GetListItem(channelID, listItemID string) (*ListItem, error)
	UpdateListItem(channelID, listItemID string, listObject ListObject) (*ListItem, error)
	DeleteListItem(channelID, listItemID string) error
	CompleteListItem(channelID, listItemID string) error
	UncompleteListItem(channelID, listItemID string) error
}

type MembersService

type MembersService interface {
	UpdateMemberNickname(userId string, nickname string) (*NicknameResponse, error)
	DeleteMemberNickname(userId string) error
	GetServerMember(serverId string, userId string) (*ServerMember, error)
	KickMember(userId string) error
	BanMember(userId string, reason string) (*ServerMemberBan, error)
	IsMemberBanned(userId string) (*ServerMemberBan, error)
	UnbanMember(userId string) error
	GetServerMembers() (*[]ServerMemberSummary, error)
}

type Mentions added in v0.1.4

type Mentions struct {
	// Info on mentioned users (min items 1)
	Users []MentionsUser `json:"users,omitempty"`

	// Info on mentioned channels (min items 1)
	Channels []MentionsChannel `json:"channels,omitempty"`

	// Info on mentioned roles (min items 1)
	Roles []MentionsRole `json:"roles,omitempty"`

	// If @everyone was mentioned
	Everyone bool `json:"everyone,omitempty"`

	// If @here was mentioned
	Here bool `json:"here,omitempty"`
}

type MentionsChannel added in v0.1.4

type MentionsChannel struct {
	// The ID of the channel
	ID string `json:"id"`
}

type MentionsRole added in v0.1.4

type MentionsRole struct {
	// The ID of the role
	ID int `json:"id"`
}

type MentionsUser added in v0.1.4

type MentionsUser struct {
	// The ID of the user
	ID string `json:"id"`
}

type MessageObject

type MessageObject struct {
	// If set, this message will only be seen by those mentioned or replied to
	IsPrivate bool `json:"isPrivate,omitempty"`

	// If set, this message will not notify any mentioned users or roles (default false)
	IsSilent bool `json:"isSilent,omitempty"`

	// Message IDs to reply to (min items 1; max items 5)
	ReplyMessageIds []string `json:"replyMessageIds,omitempty"`

	// The content of the message (min length 1; max length 4000)
	Content string `json:"content,omitempty"`

	// At this time, only one embed is supported per message, and attachments are not supported.
	// If you need to send more than one embed or upload attachments, consider creating the
	// message via a webhook. (min items 1; max items 1)
	Embeds []ChatEmbed `json:"embeds,omitempty"`
}

type MessageResponse

type MessageResponse struct {
	Message ChatMessage `json:"message"`
}

type NewChannelObject added in v0.1.3

type NewChannelObject struct {
	Name       string `json:"name"`
	Topic      string `json:"topic,omitempty"`
	IsPublic   bool   `json:"isPublic,omitempty"`
	Type       string `json:"type"`
	ServerID   string `json:"serverId,omitempty"`
	GroupID    string `json:"groupId,omitempty"`
	CategoryID int    `json:"categoryId,omitempty"`
	ParentID   string `json:"parentId,omitempty"`
	MessageID  string `json:"messageId,omitempty"`
}

type NicknameResponse

type NicknameResponse struct {
	Nickname string `json:"nickname"`
}

type RawEvent added in v0.1.2

type RawEvent struct {
	T    string          `json:"t"`
	S    string          `json:"s"`
	Data json.RawMessage `json:"d"`
}

type RawEvent2 added in v1.0.1

type RawEvent2 struct {
	OP   int             `json:"op"`
	T    string          `json:"t"`
	S    string          `json:"s"`
	Data json.RawMessage `json:"d"`
}

type ReactionService added in v0.3.0

type ReactionService interface {
	AddReactionEmote(channelId string, contentId string, emoteId int) error
	DeleteReactionEmote(channelId string, contentId string, emoteId int) error
	AddTopicReactionEmote(channelId string, topicId int, emoteId int) error
	DeleteTopicReactionEmote(channelId string, topicId int, emoteId int) error
}

type RoleService added in v0.1.1

type RoleService interface {
	AddMemberToGroup(groupId string, userId string)
	RemoveMemberFromGroup(groupId string, userId string)
}

type Server added in v0.1.4

type Server struct {
	ID         string `json:"id"`
	OwnerID    string `json:"ownerid"`
	Type       string `json:"type,omitempty"`
	Name       string `json:"name"`
	URL        string `json:"url,omitempty"`
	About      string `json:"about,omitempty"`
	Avatar     string `json:"avatar,omitempty"`
	Banner     string `json:"banner,omitempty"`
	Timezone   string `json:"timezone,omitempty"`
	IsVerified bool   `json:"isVerified,omitempty"`

	// The channel ID of the default channel of the server.
	// This channel is defined as the first chat or voice channel in the left sidebar of a server in our UI.
	// This channel is useful for sending welcome messages,
	// though note that a bot may not have permissions to interact with this channel depending on how the server is configured.
	DefaultChannelId string `json:"defaultChannelId,omitempty"`
	CreatedAt        string `json:"createdAt"`
}

type ServerChannel added in v0.1.3

type ServerChannel struct {
	ID string `json:"id"`

	// The type of channel. This will determine what routes to use for creating content in a channel.
	// For example, if this "chat", then one must use the routes for creating channel messages
	Type string `json:"type"`

	Name string `json:"name"`

	// The topic of the channel. Not applicable to threads (min length 1; max length 512)
	Topic string `json:"topic,omitempty"`

	CreatedAt string `json:"createdAt"`
	CreatedBy string `json:"createdBy"`
	UpdatedAt string `json:"updatedAt,omitempty"`
	ServerID  string `json:"serverId"`

	// ID of the root channel or thread in the channel hierarchy.
	// Only applicable to "chat", "voice", and "stream" channels and indicates that this channel is a thread, if present
	RootID string `json:"rootId,omitempty"`

	// ID of the immediate parent channel or thread in the channel hierarchy.
	// Only applicable to "chat", "voice", and "stream" channels and indicates that this channel is a thread, if present
	ParentID string `json:"parentId,omitempty"`

	// The ID of the message that this channel was created off of.
	// Only applicable to "chat", "voice", and "stream" channels and indicates that this channel is a thread, if present
	MessageID string `json:"messageId,omitempty"`

	// The category that the channel exists in. Only relevant for server channels
	CategoryID int    `json:"categoryId,omitempty"`
	GroupID    string `json:"groupId"`
	IsPublic   bool   `json:"isPublic,omitempty"`
	ArchivedBy string `json:"archivedBy,omitempty"`
	ArchivedAt string `json:"archivedAt,omitempty"`
}

type ServerChannelCreated added in v0.1.3

type ServerChannelCreated struct {
	ServerID string        `json:"serverId"`
	Channel  ServerChannel `json:"channel"`
}

type ServerChannelDeleted added in v0.2.0

type ServerChannelDeleted struct {
	ServerID string        `json:"serverId"`
	Channel  ServerChannel `json:"channel"`
}

type ServerChannelResponse added in v0.1.3

type ServerChannelResponse struct {
	Channel ServerChannel `json:"channel"`
}

type ServerChannelUpdated added in v0.1.4

type ServerChannelUpdated struct {
	ServerID string        `json:"serverId"`
	Channel  ServerChannel `json:"channel"`
}

type ServerMember

type ServerMember struct {
	User User `json:"user"`

	// (must have unique items true)
	RoleIds []int `json:"roleIds"`

	Nickname string `json:"nickname,omitempty"`

	// The ISO 8601 timestamp that the member was created at
	JoinedAt string `json:"joinedAt"`

	// (default false)
	IsOwner bool `json:"isOwner,omitempty"`
}

type ServerMemberBan

type ServerMemberBan struct {
	User UserSummary `json:"user"`

	// The reason for the ban as submitted by the banner
	Reason string `json:"reason,omitempty"`

	// The ID of the user who created this server member ban
	CreatedBy string `json:"createdBy"`

	// The ISO 8601 timestamp that the server member ban was created at
	CreatedAt string `json:"createdAt"`
}

type ServerMemberBanned added in v0.1.4

type ServerMemberBanned struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	ServerMemberBan `json:"serverMemberBan"`
}

type ServerMemberJoined added in v0.1.4

type ServerMemberJoined struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	Member ServerMember `json:"member"`
}

type ServerMemberPermissions added in v0.5.2

type ServerMemberPermissions struct {
	Permissions []string `json:"permissions"`
}

type ServerMemberRemoved added in v0.1.4

type ServerMemberRemoved struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	// The ID of the user
	UserID string `json:"userId"`

	// If this member leaving was the result of a kick
	IsKick bool `json:"isKick,omitempty"`

	// If this member leaving was the result of a ban
	IsBan bool `json:"isBan,omitempty"`
}

type ServerMemberResponse

type ServerMemberResponse struct {
	Member ServerMember `json:"member"`
}

type ServerMemberSummary

type ServerMemberSummary struct {
	User UserSummary `json:"user"`

	// (must have unique items true)
	RoleIds []int `json:"roleIds"`
}

type ServerMemberUnbanned added in v0.1.4

type ServerMemberUnbanned struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	ServerMemberBan `json:"serverMemberBan"`
}

type ServerMemberUpdated added in v0.1.4

type ServerMemberUpdated struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	UserInfo struct {
		// The ID of the user
		ID string `json:"userId"`

		// The nickname that was just updated for the user
		Nickname string `json:"nickname,omitempty"`
	} `json:"userInfo"`
}

type ServerResponse added in v0.1.4

type ServerResponse struct {
	Server `json:"server"`
}

type ServerRolesUpdated added in v0.2.0

type ServerRolesUpdated struct {
	// The ID of the server
	ServerID string `json:"serverId"`

	MemberRoleIds struct {
		UserID  string `json:"userId"`
		RoleIDs []int  `json:"roleIds"`
	} `json:"memberRoleIds"`
}

type ServerService added in v0.1.4

type ServerService interface {
	GetServer(serverId string) (*Server, error)
}

type ServerWebhookCreated added in v0.2.0

type ServerWebhookCreated struct {
	ServerID string `json:"serverId"`
	Webhook  `json:"webhook"`
}

type ServerWebhookUpdated added in v0.2.0

type ServerWebhookUpdated struct {
	ServerID string `json:"serverId"`
	Webhook  `json:"webhook"`
}

type ServerXPService added in v0.4.0

type ServerXPService interface {
	AwardXP(serverID, userID string, xpObject *XPObject) (*AwardXPResponse, error)
	SetMemberXP(serverID, userID string, xpObject *XPObject) (*AwardXPResponse, error)
	AwardRoleXP(serverID, roleID string, xpObject *XPObject) error
}
type SocialLink struct {
	Handle    string `json:"handle,omitempty"`
	ServiceID string `json:"serviceId,omitempty"`
	Type      string `json:"type"`
}

type SocialResponse added in v0.4.3

type SocialResponse struct {
	SocialLink `json:"socialLink"`
}

type SocialsService added in v0.4.3

type SocialsService interface {
	GetMemberSocialLinks(serverID string, userID string, socialType string) (*SocialLink, error)
}

type UpdateChannelObject added in v0.1.4

type UpdateChannelObject struct {
	Name     string `json:"name,omitempty"`
	Topic    string `json:"topic,omitempty"`
	IsPublic bool   `json:"isPublic,omitempty"`
}

type UpdateTopicObject added in v0.2.0

type UpdateTopicObject struct {
	Title   string `json:"title,omitempty"`
	Content string `json:"content,omitempty"`
}

type User

type User struct {
	// The ID of the user
	Id string `json:"id"`

	// The type of user. If this property is absent, it can assumed to be of type user
	Type string `json:"type,omitempty"`

	Name string `json:"name"`

	// The avatar image associated with the user
	Avatar string `json:"avatar,omitempty"`

	// The banner image associated with the user
	Banner string `json:"banner,omitempty"`

	// The ISO 8601 timestamp that the user was created at
	CreatedAt string `json:"createdAt"`

	Status UserStatus `json:"status,omitempty"`
}

type UserResponse added in v0.5.3

type UserResponse struct {
	User `json:"user"`
}

type UserService added in v0.5.3

type UserService interface {
	GetUser(id string) (*User, error)
	GetUsersServers(id string) ([]Server, error)
	UpdateStatus(id string, status UserStatusUpdate) error
	DeleteStatus(id string) error
}

type UserStatus added in v0.5.3

type UserStatus struct {
	Content string `json:"content,omitempty"`
	EmoteID int    `json:"emoteId"`
}

type UserStatusUpdate added in v0.5.3

type UserStatusUpdate struct {
	Content   string `json:"content,omitempty"`
	EmoteID   int    `json:"emoteId"`
	ExpiresAt string `json:"expiresAt,omitempty"`
}

type UserSummary

type UserSummary struct {
	// The ID of the user
	Id string `json:"id"`

	//  The type of user. If this property is absent, it can assumed to be of type user
	Type string `json:"type,omitempty"`

	Name string `json:"name"`

	// The avatar image associated with the user
	Avatar string `json:"avatar,omitempty"`
}

type Webhook added in v0.1.1

type Webhook struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	ServerID  string `json:"serverId"`
	ChannelID string `json:"channelId"`
	CreatedAt string `json:"createdAt"`
	CreatedBy string `json:"createdBy"`
	DeletedAt string `json:"deletedAt"`
	Token     string `json:"string"`
}

type WebhookObject added in v0.3.0

type WebhookObject struct {
	Name      string `json:"name"`
	ChannelID string `json:"channelId"`
}

type WebhookService added in v0.3.0

type WebhookService interface {
	CreateWebhook(serverId string, webhookObject *WebhookObject) (*Webhook, error)
	GetWebhooks(serverId string) ([]Webhook, error)
	GetWebhook(serverId string, webhookId string) (*Webhook, error)
	UpdateWebhook(serverId string, webhookId string, webhookObject *WebhookObject) (*Webhook, error)
	DeleteWebhook(serverId string, webhookId string) error
}

type WelcomeOP added in v1.0.1

type WelcomeOP struct {
	HeartbeatInterval int `json:"heartbeatIntervalMs"`
}

type XPObject added in v0.4.0

type XPObject struct {
	Amount int `json:"amount"`
}

Directories

Path Synopsis
pkg
ban

Jump to

Keyboard shortcuts

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