guildrone

package module
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

README

GuilDrone

Go Reference Release Go Report Card codebeat badge

This is a Guilded chat library based on discordgo by bwmarrin.

This is basically bwmarrin's code, so please leave all thanks to him.

Getting Started

Installing

This assumes you already have a working Go environment, if not please see this page first.

go get will always pull the latest tagged release from the master branch.

go get github.com/FlameInTheDark/guildrone
Usage

Import the package into your project.

import "github.com/FlameInTheDark/guildrone"

Construct a new Guilded client which can be used to access the variety of Guilded API functions and to set callback functions for Guilded events.

guilded, err := guildrone.New("authentication token")

See Documentation and Examples below for more detailed information.

Documentation

Index

Constants

View Source
const (

	// LogError level is used for critical errors that could lead to data loss
	// or panic that would not be returned to a calling function.
	LogError int = iota

	// LogWarning level is used for very abnormal events and errors that are
	// also returned to a calling function.
	LogWarning

	// LogInformational level is used for normal non-error activity
	LogInformational

	// LogDebug level is for very detailed non-error activity.  This is
	// very spammy and will impact performance.
	LogDebug
)
View Source
const FailedHeartbeatAcks time.Duration = 5 * time.Millisecond

FailedHeartbeatAcks is the Number of heartbeat intervals to wait until forcing a connection restart.

View Source
const VERSION = "0.3.5"

VERSION of Guildrone, follows Semantic Versioning. (http://semver.org/)

Variables

View Source
var (
	APIVersion = "1"

	EndpointGuildedWebsocket = "wss://www.guilded.gg/websocket/v1"

	EndpointGuilded  = "https://www.guilded.gg/"
	EndpointAPI      = EndpointGuilded + "api/v" + APIVersion + "/"
	EndpointChannels = EndpointAPI + "channels/"
	EndpointServers  = EndpointAPI + "servers/"
	EndpointGroups   = EndpointAPI + "groups/"

	EndpointChannel              = func(cID string) string { return EndpointChannels + cID }
	EndpointServer               = func(sID string) string { return EndpointServers + sID }
	EndpointChannelMessages      = func(cID string) string { return EndpointChannels + cID + "/messages" }
	EndpointChannelMessage       = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID }
	EndpointServerMembers        = func(sID string) string { return EndpointServers + sID + "/members" }
	EndpointServerMember         = func(sID, uID string) string { return EndpointServers + sID + "/members/" + uID }
	EndpointServerMemberNickname = func(sID, uID string) string { return EndpointServers + sID + "/members/" + uID + "/nickname" }
	EndpointServerBans           = func(sID string) string { return EndpointServers + sID + "/bans" }
	EndpointServerBansMember     = func(sID, uID string) string { return EndpointServers + sID + "/bans/" + uID }
	EndpointChannelTopics        = func(cID string) string { return EndpointChannels + cID + "/topics" }
	EndpointChannelTopic         = func(cID, tID string) string { return EndpointChannels + cID + "/topics/" + tID }
	EndpointChannelTopicPin      = func(cID, tID string) string { return EndpointChannels + cID + "/topics/" + tID + "/pin" }
	EndpointChannelItems         = func(cID string) string { return EndpointChannels + cID + "/items" }
	EndpointChannelItem          = func(cID, iID string) string { return EndpointChannels + cID + "/items/" + iID }
	EndpointChannelItemComplete  = func(cID, iID string) string { return EndpointChannels + cID + "/items/" + iID + "/complete" }
	EndpointChannelDocs          = func(cID string) string { return EndpointChannels + cID + "/docs" }
	EndpointChannelDoc           = func(cID, dID string) string { return EndpointChannels + cID + "/docs/" + dID }
	EndpointChannelEvents        = func(cID string) string { return EndpointChannels + cID + "/events" }
	EndpointChannelEvent         = func(cID, eID string) string { return EndpointChannels + cID + "/events/" + eID }
	EndpointChannelEventRsvps    = func(cID, eID string) string { return EndpointChannels + cID + "/events/" + eID + "/rsvps" }
	EndpointChannelEventRsvp     = func(cID, eID, uID string) string { return EndpointChannels + cID + "/events/" + eID + "/rsvps/" + uID }
	EndpointChannelReaction      = func(cID, coID, eID string) string {
		return EndpointChannels + cID + "/content/" + coID + "/emotes/" + eID
	}
	EndpointServerXPMember         = func(sID, uID string) string { return EndpointServers + sID + "/members/" + uID + "/xp" }
	EndpointServerXPRoles          = func(sID, rID string) string { return EndpointServers + sID + "/roles/" + rID + "/xp" }
	EndpointServerMemberSocialLink = func(sID, uID, linkType string) string {
		return EndpointServers + sID + "/members/" + uID + "/social-links/" + linkType
	}
	EndpointGroupMember       = func(gID, uID string) string { return EndpointGroups + gID + "/members/" + uID }
	EndpointServerMemberRoles = func(sID, uID string) string { return EndpointServers + sID + "/members/" + uID + "/roles" }
	EndpointServerMemberRole  = func(sID, uID, rID string) string { return EndpointServers + sID + "/members/" + uID + "/roles/" + rID }
	EndpointServerWeebhooks   = func(sID string) string { return EndpointServers + sID + "/webhooks" }
	EndpointServerWeebhook    = func(sID, wID string) string { return EndpointServers + sID + "/webhooks/" + wID }
)
View Source
var (
	ErrJSONUnmarshal = errors.New("json unmarshal")
	ErrUnauthorized  = errors.New("HTTP request was unauthorized. This could be because the provided token was not a bot token")
)

All error constants

View Source
var (
	// Marshal defines function used to encode JSON payloads
	Marshal func(v interface{}) ([]byte, error) = json.Marshal
	// Unmarshal defines function used to decode JSON payloads
	Unmarshal func(src []byte, v interface{}) error = json.Unmarshal
)
View Source
var ErrWSAlreadyOpen = errors.New("web socket already opened")

ErrWSAlreadyOpen is thrown when you attempt to open a websocket that already is open.

View Source
var ErrWSNotFound = errors.New("no websocket connection exists")

ErrWSNotFound is thrown when you attempt to use a websocket that doesn't exist

View Source
var Logger func(msgL, caller int, format string, a ...interface{})

Logger can be used to replace the standard logging for guildrone

Functions

This section is empty.

Types

type APIErrorMessage

type APIErrorMessage struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

An APIErrorMessage is an api error message returned from Guilded

type BotUser

type BotUser struct {
	ID        string    `json:"id"`
	BotID     string    `json:"botId"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
	CreatedBy string    `json:"createdBy"`
}

BotUser is a bot data structure.

type CalendarEvent

type CalendarEvent struct {
	ID          string    `json:"id"`
	ServerId    string    `json:"serverId"`
	ChannelId   string    `json:"channelId"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Location    string    `json:"location"`
	URL         string    `json:"url"`
	Color       int       `json:"color"`
	StartsAt    time.Time `json:"startsAt"`
	// Duration in minutes
	Duration     int          `json:"duration"`
	IsPrivate    bool         `json:"isPrivate"`
	Mentions     *Mentions    `json:"mentions"`
	CreatedAt    time.Time    `json:"createdAt"`
	CreatedBy    string       `json:"createdBy"`
	Cancellation Cancellation `json:"cancellation"`
}

type CalendarEventCreated

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

type CalendarEventDeleted

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

type CalendarEventRsvp added in v0.3.1

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

type CalendarEventRsvpDeleted added in v0.3.1

type CalendarEventRsvpDeleted struct {
	ServerID          string            `json:"serverId"`
	CalendarEventRsvp CalendarEventRsvp `json:"calendarEventRsvp"`
}

type CalendarEventRsvpManyUpdated added in v0.3.1

type CalendarEventRsvpManyUpdated struct {
	ServerID           string              `json:"serverId"`
	CalendarEventRsvps []CalendarEventRsvp `json:"calendarEventRsvps"`
}

type CalendarEventRsvpUpdated added in v0.3.1

type CalendarEventRsvpUpdated struct {
	ServerID          string            `json:"serverId"`
	CalendarEventRsvp CalendarEventRsvp `json:"calendarEventRsvp"`
}

type CalendarEventUpdated

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

type CalendarSetRsvpStatusRrequest added in v0.3.1

type CalendarSetRsvpStatusRrequest struct {
	Status RsvpStatus `json:"status"`
}

type Cancellation

type Cancellation struct {
	Description string `json:"description"`
	CreatedBy   string `json:"createdBy"`
}

type ChannelDoc

type ChannelDoc struct {
	Title   string `json:"title" validate:"min=1"`
	Content string `json:"content"`
}

func (*ChannelDoc) Validate added in v0.1.1

func (c *ChannelDoc) Validate() error

Validate validates the channel doc create/update request Returns nil if valid, otherwise returns an error

type ChannelEvent

type ChannelEvent struct {
	Name        string     `json:"name" validate:"min=1,max=60"`
	Description string     `json:"description,omitempty" validate:"omitempty,min=1,max=8000"`
	Location    string     `json:"location,omitempty" validate:"omitempty,min=1,max=8000"`
	StartsAt    *time.Time `json:"startsAt,omitempty"`
	URL         string     `json:"url,omitempty"`
	Color       int        `json:"color,omitempty" validate:"omitempty,min=0,max=16777215"`
	Duration    int        `json:"duration,omitempty" validate:"omitempty,min=1"`
	IsPrivate   bool       `json:"isPrivate,omitempty"`
}

ChannelEvent is the request body for creating/updating a channel event

func (*ChannelEvent) Validate added in v0.1.1

func (e *ChannelEvent) Validate() error

Validate validates the channel event create/update request Returns nil if valid, otherwise returns an error

type ChannelEventsRequest

type ChannelEventsRequest struct {
	Before *time.Time `json:"before,omitempty"`
	After  *time.Time `json:"after,omitempty"`
	Limit  int        `json:"limit,omitempty" validate:"omitempty,min=1,max=500"`
}

ChannelEventsRequest is the request body for listing channel events

func (*ChannelEventsRequest) Validate added in v0.1.1

func (e *ChannelEventsRequest) Validate() error

Validate validates the channel events request Returns nil if valid, otherwise returns an error

type ChannelForumTopicCreate

type ChannelForumTopicCreate struct {
	Title   string `json:"title" validate:"min=1"`
	Content string `json:"content"`
}

ChannelForumTopicCreate is the request body for creating a forum topic

func (*ChannelForumTopicCreate) Validate added in v0.1.1

func (c *ChannelForumTopicCreate) Validate() error

Validate validates the channel forum topic create request Returns nil if valid, otherwise returns an error

type ChannelForumTopicUpdate added in v0.3.0

type ChannelForumTopicUpdate struct {
	Title   string `json:"title,omitempty" validate:"min=1,max=500"`
	Content string `json:"content,omitempty"`
}

ChannelForumTopicUpdate is the request body for updating a forum topic

func (*ChannelForumTopicUpdate) Validate added in v0.3.0

func (c *ChannelForumTopicUpdate) Validate() error

Validate validates the channel forum topic update request

type ChannelListItem

type ChannelListItem struct {
	Message string               `json:"message"`
	Note    *ChannelListItemNote `json:"note,omitempty"`
}

ChannelListItem is the request body for creating or updating a channel list item

type ChannelListItemNote

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

type ChannelMessageReactionCreated

type ChannelMessageReactionCreated struct {
	ServerID string   `json:"serverId"`
	Reaction Reaction `json:"reaction"`
}

type ChannelMessageReactionDeleted

type ChannelMessageReactionDeleted struct {
	ServerID string   `json:"serverId"`
	Reaction Reaction `json:"reaction"`
}

type ChatEmbed

type ChatEmbed struct {
	Title       string              `json:"title,omitempty" validate:"max=256"`
	Description string              `json:"description,omitempty" validate:"max=2048"`
	URL         string              `json:"url,omitempty" validate:"url,max=1024"`
	Color       int                 `json:"color" validate:"min=0,max=16777215"`
	Footer      *ChatEmbedFooter    `json:"footer,omitempty" validate:"omitempty,dive"`
	Timestamp   *time.Time          `json:"timestamp,omitempty" validate:"omitempty,dive"`
	Thumbnail   *ChatEmbedThumbnail `json:"thumbnail,omitempty" validate:"omitempty,dive"`
	Image       *ChatEmbedImage     `json:"image,omitempty" validate:"omitempty,dive"`
	Author      *ChatEmbedAuthor    `json:"author,omitempty" validate:"omitempty,dive"`
	Fields      []ChatEmbedField    `json:"fields,omitempty" validate:"omitempty,max=25,dive"`
}

ChatEmbed stores the data of an embed

func (*ChatEmbed) Validate added in v0.1.1

func (e *ChatEmbed) Validate() error

Validate validates the ChatEmbed Returns nil if no errors were found

type ChatEmbedAuthor

type ChatEmbedAuthor struct {
	Name    string `json:"name,omitempty" validate:"max=256"`
	URL     string `json:"url,omitempty" validate:"url,max=1024"`
	IconUrl string `json:"icon_url,omitempty" validate:"url,max=1024"`
}

type ChatEmbedField

type ChatEmbedField struct {
	Name   string `json:"name" validate:"max=256"`
	Value  string `json:"value" validate:"max=1024"`
	Inline bool   `json:"inline,omitempty"`
}

type ChatEmbedFooter

type ChatEmbedFooter struct {
	Text    string `json:"text,omitempty" validate:"max=2048"`
	IconUrl string `json:"icon_url,omitempty" validate:"url,max=1024"`
}

type ChatEmbedImage

type ChatEmbedImage struct {
	URL string `json:"url,omitempty" validate:"url,max=1024"`
}

type ChatEmbedThumbnail

type ChatEmbedThumbnail struct {
	URL string `json:"url,omitempty" validate:"url,max=1024"`
}

type ChatMessage

type ChatMessage struct {
	ID                 string      `json:"id"`
	Type               MessageType `json:"type"`
	ServerID           string      `json:"serverId"`
	ChannelID          string      `json:"channelId"`
	Content            string      `json:"content"`
	Embeds             []ChatEmbed `json:"embeds" validate:"omitempty,min=1,max=10,dive"`
	ReplyMessageIds    []string    `json:"replyMessageIds" validate:"omitempty,min=1,max=5"`
	IsPrivate          bool        `json:"isPrivate"`
	IsSilent           bool        `json:"isSilent"`
	Mentions           *Mentions   `json:"mentions,omitempty" validate:"omitempty,dive"`
	CreatedAt          time.Time   `json:"createdAt"`
	CreatedBy          string      `json:"createdBy"`
	CreatedByWebhookId string      `json:"createdByWebhookId"`
	UpdatedAt          *time.Time  `json:"updatedAt,omitempty"`
}

ChatMessage stores the data of a chat message

type ChatMessageCreated

type ChatMessageCreated struct {
	ServerID string      `json:"serverId"`
	Message  ChatMessage `json:"message"`
}

Is the data for the ChatMessageCreated event

type ChatMessageDeleted

type ChatMessageDeleted struct {
	ServerID string      `json:"serverId"`
	Message  ChatMessage `json:"message"`
}

type ChatMessageUpdated

type ChatMessageUpdated struct {
	ServerID string      `json:"serverId"`
	Message  ChatMessage `json:"message"`
}

type Connect

type Connect struct{}

Connect is the data for a Connect event. This is a synthetic event and is not dispatched by Guilded.

type Disconnect

type Disconnect struct{}

Disconnect is the data for a Disconnect event. This is a synthetic event and is not dispatched by Guilded.

type Doc

type Doc struct {
	ID        int        `json:"id"`
	ServerId  string     `json:"serverId"`
	ChannelId string     `json:"channelId"`
	Title     string     `json:"title"`
	Content   string     `json:"content"`
	Mentions  *Mentions  `json:"mentions"`
	CreatedAt time.Time  `json:"createdAt"`
	CreatedBy string     `json:"createdBy"`
	UpdatedAt *time.Time `json:"updatedAt"`
	UpdatedBy string     `json:"updatedBy"`
}

type DocCreated

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

type DocDeleted

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

type DocUpdated

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

type Emote

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

Emote is a struct that represents a reaction emote.

type Event

type Event struct {
	Operation int             `json:"op"`
	MessageID string          `json:"s"`
	Type      string          `json:"t"`
	RawData   json.RawMessage `json:"d"`
	// Struct contains one of the other types in this file.
	Struct interface{} `json:"-"`
}

Event provides a basic initial struct for all websocket events.

type EventHandler

type EventHandler interface {
	// Type returns the type of event this handler belongs to.
	Type() string

	// Handle is called whenever an event of Type() happens.
	// It is the receiver's responsibility to type assert that the interface
	// is the expected struct.
	Handle(*Session, interface{})
}

EventHandler is an interface for Guilded events.

type EventInterfaceProvider

type EventInterfaceProvider interface {
	// Type is the type of event this handler belongs to.
	Type() string

	// New returns a new instance of the struct this event handler handles.
	// This is called once per event.
	// The struct is provided to all handlers of the same Type().
	New() interface{}
}

EventInterfaceProvider is an interface for providing empty interfaces for Guilded events.

type ForumTopic

type ForumTopic struct {
	ID                 int        `json:"id"`
	ServerID           string     `json:"serverId"`
	ChannelID          string     `json:"channelId"`
	Title              string     `json:"title,omitempty"`
	Content            string     `json:"content,omitempty"`
	CreatedAt          time.Time  `json:"createdAt"`
	CreatedBy          string     `json:"createdBy"`
	CreatedByWebhookId string     `json:"createdByWebhookId,omitempty"`
	UpdatedAt          *time.Time `json:"updatedAt,omitempty"`
	BumpedAt           *time.Time `json:"bumpedAt,omitempty"`
	Mentions           *Mentions  `json:"mentions,omitempty"`
}

ForumTopic is the forum topic model

type ForumTopicCreated added in v0.3.1

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

type ForumTopicDeleted added in v0.3.1

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

type ForumTopicSummary added in v0.3.0

type ForumTopicSummary struct {
	ID               int        `json:"id"`
	ServerID         string     `json:"serverId"`
	ChannelID        string     `json:"channelId"`
	Title            string     `json:"title"`
	CreatedAt        time.Time  `json:"createdAt"`
	CreatedBy        string     `json:"createdBy"`
	CreatedByWebhook string     `json:"createdByWebhook,omitempty"`
	UpdatedAt        *time.Time `json:"updatedAt,omitempty"`
	BumpedAt         *time.Time `json:"bumpedAt,omitempty"`
}

ForumTopicSummary is the forum topic summary model

type ForumTopicUpdated added in v0.3.1

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

type ListItem

type ListItem struct {
	ID                 string        `json:"id"`
	ServerID           string        `json:"serverId"`
	ChannelID          string        `json:"channelId"`
	Message            string        `json:"message"`
	Mentions           *Mentions     `json:"mentions"`
	CreatedAt          time.Time     `json:"createdAt"`
	CreatedBy          string        `json:"createdBy"`
	CreatedByWebhookId string        `json:"createdByWebhookId"`
	UpdatedAt          *time.Time    `json:"updatedAt"`
	UpdatedBy          string        `json:"updatedBy"`
	ParentListItemId   string        `json:"parentListItemId"`
	CompletedAt        string        `json:"completedAt"`
	CompletedBy        string        `json:"completedBy"`
	Note               *ListItemNote `json:"note"`
}

ListItem is a struct that represents a list item.

type ListItemCompleted

type ListItemCompleted struct {
	ServerID string   `json:"serverId"`
	ListItem ListItem `json:"listItem"`
}

type ListItemCreated

type ListItemCreated struct {
	ServerID string   `json:"serverId"`
	ListItem ListItem `json:"listItem"`
}

type ListItemDeleted

type ListItemDeleted struct {
	ServerID string   `json:"serverId"`
	ListItem ListItem `json:"listItem"`
}

type ListItemNote

type ListItemNote struct {
	CreatedAt time.Time  `json:"createdAt"`
	CreatedBy string     `json:"createdBy"`
	UpdatedAt *time.Time `json:"updatedAt"`
	UpdatedBy string     `json:"updatedBy"`
	Mentions  *Mentions  `json:"mentions"`
	Content   string     `json:"content"`
}

ListItemNote is a struct that represents a list item note.

type ListItemUpdated

type ListItemUpdated struct {
	ServerID string   `json:"serverId"`
	ListItem ListItem `json:"listItem"`
}

type MemberRole

type MemberRole struct {
	UserID  string `json:"userId"`
	RoleIDs []int  `json:"roleId"`
}

type MentionChannel

type MentionChannel struct {
	ID string `json:"id"`
}

type MentionRole

type MentionRole struct {
	ID string `json:"id"`
}

type MentionUser

type MentionUser struct {
	ID string `json:"id"`
}

type Mentions

type Mentions struct {
	Users    []MentionUser    `json:"users,omitempty" validate:"omitempty,min=1"`
	Channels []MentionChannel `json:"channels,omitempty" validate:"omitempty,min=1"`
	Roles    []MentionRole    `json:"roles,omitempty" validate:"omitempty,min=1"`
	Everyone bool             `json:"everyone,omitempty"`
	Here     bool             `json:"here,omitempty"`
}

Mentions stores the data of a mention

type MessageCreate

type MessageCreate struct {
	IsPrivate       bool        `json:"isPrivate,omitempty"`
	IsSilent        bool        `json:"isSilent,omitempty"`
	ReplyMessageIds []string    `json:"replyMessageIds,omitempty" validate:"omitempty,min=1,max=5"`
	Content         string      `json:"content,omitempty" validate:"max=4000"`
	Embeds          []ChatEmbed `json:"embeds,omitempty" validate:"omitempty,dive"`
}

MessageCreate is a request body for creating a message

func (*MessageCreate) Validate added in v0.1.1

func (m *MessageCreate) Validate() error

Validate validates the MessageCreate request body Returns nil if no errors were found

type MessageType

type MessageType string

MessageType is the type of message

const (
	MessageTypeDefault MessageType = "default"
	MessageTypeSystem  MessageType = "system"
)

type MessageUpdate

type MessageUpdate struct {
	Content string      `json:"content,omitempty" validate:"max=4000"`
	Embeds  []ChatEmbed `json:"embeds,omitempty" validate:"omitempty,dive"`
}

MessageUpdate is a request body for updating a message

func (*MessageUpdate) Validate added in v0.1.1

func (m *MessageUpdate) Validate() error

Validate validates the MessageUpdate request body Returns nil if no errors were found

type MessagesRequest

type MessagesRequest struct {
	Before         *time.Time `json:"before,omitempty"`
	After          *time.Time `json:"after,omitempty"`
	Limit          int        `json:"limit,omitempty"`
	IncludePrivate bool       `json:"includePrivate,omitempty"`
}

MessagesRequest is a request body for getting messages

type RESTError

type RESTError struct {
	Request      *http.Request
	Response     *http.Response
	ResponseBody []byte

	Message *APIErrorMessage // Message may be nil.
}

RESTError stores error information about a request with a bad response code. Message is not always present, there are cases where api calls can fail without returning a json message.

func (RESTError) Error

func (r RESTError) Error() string

Error returns a Rest API Error with its status code and body.

type RateLimit

type RateLimit struct {
	RetryAfter time.Duration
	URL        string
}

RateLimit is the data for a RateLimit event. This is a synthetic event and is not dispatched by Guilded.

type RateLimitError

type RateLimitError struct {
	*RateLimit
}

RateLimitError is returned when a request exceeds a rate limit and ShouldRetryOnRateLimit is false. The request may be manually retried after waiting the duration specified by RetryAfter.

func (RateLimitError) Error

func (e RateLimitError) Error() string

Error returns a rate limit error with rate limited endpoint and retry time.

type Reaction

type Reaction struct {
	ChannelID string `json:"channelId"`
	MessageID string `json:"messageId"`
	CreatedBy string `json:"createdBy"`
	Emote     Emote  `json:"emote"`
}

Reaction is a struct that represents a reaction.

type Ready

type Ready struct {
	LastMessageID       string  `json:"lastMessageId"`
	HeartbeatIntervalMS int     `json:"heartbeatIntervalMs"`
	User                BotUser `json:"user"`
}

type Resume added in v0.3.0

type Resume struct{}

Resume is the data for a Resume event. This is a synthetic event and is not dispatched by Guilded.

type RsvpStatus added in v0.3.1

type RsvpStatus string
const (
	RsvpStatusGoing      RsvpStatus = "going"
	RsvpStatusMaybe      RsvpStatus = "maybe"
	RsvpStatusDeclined   RsvpStatus = "declined"
	RsvpStatusInvited    RsvpStatus = "invited"
	RsvpStatusWaitlisted RsvpStatus = "waitlisted"
)

type Server

type Server struct {
	ID               string      `json:"id"`
	OwnerID          string      `json:"ownerId"`
	Type             *ServerType `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"`
	DefaultChannelID string      `json:"defaultChannelId,omitempty"`
	CreatedAt        time.Time   `json:"createdAt"`
}

Server represents a server in Guilded

type ServerChannel

type ServerChannel struct {
	ID         string            `json:"id"`
	Type       ServerChannelType `json:"type"`
	Name       string            `json:"name"`
	Topic      string            `json:"topic"`
	CreatedAt  time.Time         `json:"createdAt"`
	CreatedBy  string            `json:"createdBy"`
	UpdatedAt  *time.Time        `json:"updatedAt"`
	ServerId   string            `json:"serverId"`
	ParentId   string            `json:"parentId"`
	CategoryId int               `json:"categoryId"`
	GroupId    string            `json:"groupId"`
	IsPublic   bool              `json:"isPublic"`
	ArchivedBy string            `json:"archivedBy"`
	ArchivedAt string            `json:"archivedAt"`
}

type ServerChannelCreate added in v0.1.1

type ServerChannelCreate struct {
	Name       string            `json:"name" validate:"required,min=1,max=100"`
	Topic      string            `json:"topic,omitempty" validate:"omitempty,min=1,max=512"`
	IsPublic   bool              `json:"isPublic,omitempty"`
	Type       ServerChannelType `json:"type" validate:"required"`
	ServerID   string            `json:"serverId,omitempty"`
	GroupID    string            `json:"groupId,omitempty"`
	CategoryID string            `json:"categoryId,omitempty"`
}

ServerChannelCreate is the request body for creating a channel

func (*ServerChannelCreate) Validate added in v0.1.1

func (c *ServerChannelCreate) Validate() error

Validate validates the channel create request Returns nil if valid, otherwise returns an error

type ServerChannelType

type ServerChannelType string

ServerChannelType is a sting that represents the type of a server channel. ("announcements", "chat", "calendar", "forums", "media", "docs", "voice", "list", "scheduling", or "stream")

const (
	ServerChannelTypeAnnouncements ServerChannelType = "announcements"
	ServerChannelTypeChat          ServerChannelType = "chat"
	ServerChannelTypeCalendar      ServerChannelType = "calendar"
	ServerChannelTypeForums        ServerChannelType = "forums"
	ServerChannelTypeMedia         ServerChannelType = "media"
	ServerChannelTypeDocs          ServerChannelType = "docs"
	ServerChannelTypeVoice         ServerChannelType = "voice"
	ServerChannelTypeList          ServerChannelType = "list"
	ServerChannelTypeScheduling    ServerChannelType = "scheduling"
	ServerChannelTypeStream        ServerChannelType = "stream"
)

type ServerChannelUpdate added in v0.1.1

type ServerChannelUpdate struct {
	Name     string `json:"name,omitempty" validate:"omitempty,min=1,max=100"`
	Topic    string `json:"topic,omitempty" validate:"omitempty,min=1,max=512"`
	IsPublic bool   `json:"isPublic,omitempty"`
}

ServerChannelUpdate is the request body for updating a channel

func (*ServerChannelUpdate) Validate added in v0.1.1

func (c *ServerChannelUpdate) Validate() error

Validate validates the channel update request Returns nil if valid, otherwise returns an error

type ServerMember

type ServerMember struct {
	User     User   `json:"user"`
	RoleIds  []int  `json:"roleIds"`
	Nickname string `json:"nickname"`
	JoinedAt string `json:"joinedAt"`
	IsOwner  bool   `json:"isOwner"`
}

type ServerMemberBan

type ServerMemberBan struct {
	UserSummary UserSummary `json:"user"`
	Reason      string      `json:"reason"`
	CreatedBy   string      `json:"createdBy"`
	CreatedAt   time.Time   `json:"createdAt"`
}

type ServerMemberBanCreate

type ServerMemberBanCreate struct {
	Reason string `json:"reason"`
}

ServerMemberBanCreate is the request body for banning a user from a server

type ServerMemberNicknameUpdate

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

ServerMemberNicknameUpdate is the request body for updating a server member nickname

type ServerSocialLink struct {
	Handle    string `json:"handle,omitempty"`
	ServiceID string `json:"serviceId,omitempty"`
	Type      string `json:"type"`
}

ServerSocialLink is the request body for retrieving server member social link

type ServerType

type ServerType string
const (
	ServerTypeTeam         ServerType = "team"
	ServerTypeOrganization ServerType = "organization"
	ServerTypeCommunity    ServerType = "community"
	ServerTypeClan         ServerType = "clan"
	ServerTypeGuild        ServerType = "guild"
	ServerTypeFriends      ServerType = "friends"
	ServerTypeStreaming    ServerType = "streaming"
	ServerTypeOther        ServerType = "other"
)

type ServerXPSet added in v0.3.4

type ServerXPSet struct {
	Total int `json:"total" validate:"min=-1000000000,max=1000000000"`
}

ServerXPSet is the request body for set a server member xp

type ServerXPUpdate

type ServerXPUpdate struct {
	Amount int `json:"amount" validate:"min=-1000,max=1000"`
}

ServerXPUpdate is the request body for updating a server member xp

func (*ServerXPUpdate) Validate added in v0.1.1

func (xp *ServerXPUpdate) Validate() error

Validate validates the server member xp update request Returns nil if valid, otherwise returns an error

type Session

type Session struct {
	sync.RWMutex

	// Authentication token for this session
	Token string

	// Logging
	Debug    bool
	LogLevel int

	// REST API Client
	Client    *http.Client
	UserAgent string

	// Max number of REST API retries
	MaxRestRetries int

	// Should the session reconnect the websocket on errors.
	ShouldReconnectOnError bool

	LastEventID string

	// Should replay missed events on websocket reconnect
	ShouldReplayEventsOnReconnect bool

	// Should the session retry requests when rate limited.
	ShouldRetryOnRateLimit bool

	// Whether or not to call event handlers synchronously.
	// e.g false = launch event handlers in their own goroutines.
	SyncEvents bool

	// Whether the Data Websocket is ready
	DataReady bool // NOTE: Maye be deprecated soon

	// Stores the last HeartbeatAck that was received (in UTC)
	LastHeartbeatAck time.Time

	// Stores the last Heartbeat sent (in UTC)
	LastHeartbeatSent time.Time
	// contains filtered or unexported fields
}

func New

func New(token string) (s *Session, err error)

New creates a new Guilded session with provided token

func (*Session) AddHandler

func (s *Session) AddHandler(handler interface{}) func()

AddHandler allows you to add an event handler that will be fired anytime the Guilded WSAPI event that matches the function fires. The first parameter is a *Session, and the second parameter is a pointer to a struct corresponding to the event for which you want to listen.

eg:

Session.AddHandler(func(s *guildrone.Session, m *guildrone.MessageCreated) {
})

or:

Session.AddHandler(func(s *guildrone.Session, m *guildrone.PresenceUpdate) {
})

List of events can be found at this page, with corresponding names in the library for each event: https://www.guilded.gg/docs/api/websockets There are also synthetic events fired by the library internally which are available for handling, like Connect, Disconnect, and RateLimit. events.go contains all of the Guilded WSAPI and synthetic events that can be handled.

The return value of this method is a function, that when called will remove the event handler.

func (*Session) AddHandlerOnce

func (s *Session) AddHandlerOnce(handler interface{}) func()

AddHandlerOnce allows you to add an event handler that will be fired the next time the Guilded WSAPI event that matches the function fires. See AddHandler for more details.

func (*Session) ChannelContentReactionAdd

func (s *Session) ChannelContentReactionAdd(channelID, contentID string, emoteID int) error

ChannelContentReactionAdd adds a reaction to a content in a channel. channelID : The ID of a Channel. contentID : The ID of a Content. emoteID : The ID of an Emote.

func (*Session) ChannelContentReactionDelete

func (s *Session) ChannelContentReactionDelete(channelID, contentID string, emoteID int) error

ChannelContentReactionDelete deletes a reaction to a content in a channel. channelID : The ID of a Channel. contentID : The ID of a Content. emoteID : The ID of an Emote.

func (*Session) ChannelCreate

func (s *Session) ChannelCreate(data *ServerChannelCreate) (*ServerChannel, error)

ServerChannelCreate creates a channel in a server. data : The channel struct to send.

func (*Session) ChannelDelete

func (s *Session) ChannelDelete(channelID string) error

ChannelDelete deletes a channel. channelID : The ID of a Channel.

func (*Session) ChannelDoc

func (s *Session) ChannelDoc(channelID string, docID int) (*Doc, error)

ChannelDoc returns a doc in a channel. channelID : The ID of a Channel. docID : The ID of a Doc.

func (*Session) ChannelDocCreate

func (s *Session) ChannelDocCreate(channelID string, data *ChannelDoc) (*Doc, error)

ChannelDocCreate creates a doc in a channel. channelID : The ID of a Channel. data : The data for the doc.

func (*Session) ChannelDocDelete

func (s *Session) ChannelDocDelete(channelID string, docID int) error

ChannelDocDelete deletes a doc in a channel. channelID : The ID of a Channel. docID : The ID of a Doc.

func (*Session) ChannelDocUpdate

func (s *Session) ChannelDocUpdate(channelID string, docID int, data *ChannelDoc) (*Doc, error)

ChannelDocUpdate updates a doc in a channel. channelID : The ID of a Channel. docID : The ID of a Doc. data : The data for the doc.

func (*Session) ChannelDocs

func (s *Session) ChannelDocs(channelID string) ([]*Doc, error)

ChannelDocs returns an array of docs in a channel. channelID : The ID of a Channel.

func (*Session) ChannelEvent

func (s *Session) ChannelEvent(channelID string, eventID int) (*CalendarEvent, error)

ChannelEvent returns a calendar event in a channel. channelID : The ID of a Channel. eventID : The ID of an CalendarEvent.

func (*Session) ChannelEventCreate

func (s *Session) ChannelEventCreate(channelID string, data *ChannelEvent) (*CalendarEvent, error)

ChannelEventCreate creates a calendar event in a channel. channelID : The ID of a Channel. data : The data for the event.

func (*Session) ChannelEventDelete

func (s *Session) ChannelEventDelete(channelID string, eventID int) error

ChannelEventDelete deletes a calendar event in a channel. channelID : The ID of a Channel. eventID : The ID of an CalendarEvent.

func (*Session) ChannelEventRsvp added in v0.3.1

func (s *Session) ChannelEventRsvp(channelID string, eventID int, userID string) (*CalendarEventRsvp, error)

ChannelEventRsvp returns a calendar event rsvp in a channel. channelID : The ID of a Channel. eventID : The ID of an CalendarEvent. userID : The ID of a User.

func (*Session) ChannelEventRsvpDelete added in v0.3.1

func (s *Session) ChannelEventRsvpDelete(channelID string, eventID int, userID string) error

ChannelEventRsvpDelete deletes a calendar event rsvp in a channel. channelID : The ID of a Channel. eventID : The ID of an CalendarEvent. userID : The ID of a User.

func (*Session) ChannelEventRsvpSet added in v0.3.1

func (s *Session) ChannelEventRsvpSet(channelID string, eventID int, userID string, status RsvpStatus) (*CalendarEventRsvp, error)

ChannelEventRsvpSet create or update a calendar event rsvp in a channel. channelID : The ID of a Channel. eventID : The ID of an CalendarEvent. userID : The ID of a User. status : The status of the rsvp.

func (*Session) ChannelEventRsvps added in v0.3.1

func (s *Session) ChannelEventRsvps(channelID string, eventID int) ([]*CalendarEventRsvp, error)

ChannelEventRsvps returns an array of calendar event rsvps in a channel. channelID : The ID of a Channel. eventID : The ID of an CalendarEvent.

func (*Session) ChannelEventUpdate

func (s *Session) ChannelEventUpdate(channelID string, eventID int, data *ChannelEvent) (*CalendarEvent, error)

ChannelEventUpdate updates a calendar event in a channel. channelID : The ID of a Channel. eventID : The ID of an CalendarEvent. data : The data for the event.

func (*Session) ChannelEvents

func (s *Session) ChannelEvents(channelID string, before, after *time.Time, limit int) ([]*CalendarEvent, error)

ChannelEvents returns an array of calendar events in a channel. channelID : The ID of a Channel. data : The data for the event.

func (*Session) ChannelForumTopic added in v0.3.0

func (s *Session) ChannelForumTopic(channelID string, topicID int) (*ForumTopic, error)

ChannelForumTopic returns a topic in a channel. channelID : The ID of a Channel. topicID : The ID of a Topic.

func (*Session) ChannelForumTopicCreate

func (s *Session) ChannelForumTopicCreate(channelID, title, content string) (*ForumTopic, error)

ChannelForumTopicCreate creates a topic in a channel. channelID : The ID of a Channel. title : The title of the topic. content : The content of the topic.

func (*Session) ChannelForumTopicDelete added in v0.3.0

func (s *Session) ChannelForumTopicDelete(channelID string, topicID int) error

ChannelForumTopicDelete deletes a topic in a channel. channelID : The ID of a Channel. topicID : The ID of a Topic.

func (*Session) ChannelForumTopicPin added in v0.3.5

func (s *Session) ChannelForumTopicPin(channelID string, topicID int) error

ChannelForumTopicPin pins a topic in a channel. channelID : The ID of a Channel. topicID : The ID of a Topic.

func (*Session) ChannelForumTopicUnpin added in v0.3.5

func (s *Session) ChannelForumTopicUnpin(channelID string, topicID int) error

ChannelForumTopicUnpin unpins a topic in a channel. channelID : The ID of a Channel. topicID : The ID of a Topic.

func (*Session) ChannelForumTopicUpdate added in v0.3.0

func (s *Session) ChannelForumTopicUpdate(channelID string, topicID int, data *ChannelForumTopicUpdate) (*ForumTopic, error)

ChannelForumTopicUpdate updates a topic in a channel. channelID : The ID of a Channel. topicID : The ID of a Topic. data : The data for the topic.

func (*Session) ChannelForumTopics added in v0.3.0

func (s *Session) ChannelForumTopics(channelID string, before *time.Time, limit int) ([]ForumTopicSummary, error)

ChannelForumTopics returns an array of topics in a channel. channelID : The ID of a Channel. before : The timestamp of the oldest topic to return. limit : The maximum number of topics to return.

func (*Session) ChannelGet

func (s *Session) ChannelGet(channelID string) (*ServerChannel, error)

ChannelGet returns a channel. channelID : The ID of a Channel.

func (*Session) ChannelListItem

func (s *Session) ChannelListItem(channelID, itemID string) (*ListItem, error)

ChannelListItem returns a list item in a channel. channelID : The ID of a Channel. itemID : The ID of a ListItem.

func (*Session) ChannelListItemComplete

func (s *Session) ChannelListItemComplete(channelID, itemID string) error

ChannelListItemComplete completes a list item in a channel. channelID : The ID of a Channel. itemID : The ID of a ListItem.

func (*Session) ChannelListItemCreate

func (s *Session) ChannelListItemCreate(channelID string, data *ChannelListItem) (*ListItem, error)

ChannelListItemCreate creates a list item in a channel. channelID : The ID of a Channel. data : The data for the list item.

func (*Session) ChannelListItemDelete

func (s *Session) ChannelListItemDelete(channelID, itemID string) error

ChannelListItemDelete deletes a list item in a channel. channelID : The ID of a Channel. itemID : The ID of a ListItem.

func (*Session) ChannelListItemUncomplete

func (s *Session) ChannelListItemUncomplete(channelID, itemID string) error

ChannelListItemUncomplete uncompletes a list item in a channel. channelID : The ID of a Channel. itemID : The ID of a ListItem.

func (*Session) ChannelListItemUpdate

func (s *Session) ChannelListItemUpdate(channelID, itemID string, data *ChannelListItem) (*ListItem, error)

ChannelListItemUpdate updates a list item in a channel. channelID : The ID of a Channel. itemID : The ID of a ListItem. data : The data for the list item.

func (*Session) ChannelListItems

func (s *Session) ChannelListItems(channelID string) ([]*ListItem, error)

ChannelListItems returns an array of list items in a channel without notes content. channelID : The ID of a Channel.

func (*Session) ChannelMessage

func (s *Session) ChannelMessage(channelID string, messageID string) (*ChatMessage, error)

ChannelMessage returns a message from a channel. channelID : The ID of a Channel. messageID : The ID of a Message.

func (*Session) ChannelMessageCreate

func (s *Session) ChannelMessageCreate(channelID string, content string) (*ChatMessage, error)

ChannelMessageCreate sends a message to the given channel. channelID : The ID of a Channel. content : The message to send.

func (*Session) ChannelMessageCreateComplex

func (s *Session) ChannelMessageCreateComplex(channelID string, data *MessageCreate) (st *ChatMessage, err error)

ChannelMessageCreateComplex sends a message to the given channel. channelID : The ID of a Channel. data : The message struct to send.

func (*Session) ChannelMessageDelete

func (s *Session) ChannelMessageDelete(channelID, messageID string) error

ChannelMessageDelete deletes a message in a channel. channelID : The ID of a Channel. messageID : The ID of a Message.

func (*Session) ChannelMessageUpdate

func (s *Session) ChannelMessageUpdate(channelID, messageID string, data *MessageUpdate) (*ChatMessage, error)

ChannelMessageUpdate updates a message in a channel. channelID : The ID of a Channel. messageID : The ID of a Message. data : The message struct to send.

func (*Session) ChannelMessages

func (s *Session) ChannelMessages(channelID string, limit int, beforeTime, afterTime *time.Time, includePrivate bool) ([]*ChatMessage, error)

ChannelMessages returns an array of messages from a channel. channelID : The ID of a Channel. limit : The number of messages to return. beforeTime : The time before which messages are to be returned. afterTime : The time after which messages are to be returned. includePrivate : Whether to include private messages.

func (*Session) ChannelUpdate

func (s *Session) ChannelUpdate(channelID string, data *ServerChannelUpdate) (*ServerChannel, error)

ServerChannelUpdate updates a channel. channelID : The ID of a Channel. data : The channel struct to send.

func (*Session) Close

func (s *Session) Close() error

Close closes a websocket and stops all listening/heartbeat goroutines.

func (*Session) CloseWithCode

func (s *Session) CloseWithCode(closeCode int) (err error)

CloseWithCode closes a websocket using the provided closeCode and stops all listening/heartbeat goroutines.

func (*Session) GroupMemberAdd

func (s *Session) GroupMemberAdd(groupID, userID string) error

GroupMemberAdd adds a member to a group. groupID : The ID of a Group. memberID : The ID of a Member.

func (*Session) GroupMemberRemove

func (s *Session) GroupMemberRemove(groupID, userID string) error

GroupMemberRemove removes a member from a group. groupID : The ID of a Group. memberID : The ID of a Member.

func (*Session) Open

func (s *Session) Open() error

Open creates a websocket connection to Guilded. See: https://www.guilded.gg/docs/api/connecting

func (*Session) Request

func (s *Session) Request(method, urlStr string, data interface{}) (response []byte, err error)

Request is the same as RequestWithBucketID but the bucket id is the same as the urlStr

func (*Session) RequestCall

func (s *Session) RequestCall(method, urlStr, contentType string, b []byte, sequence int) (response []byte, err error)

RequestCall makes a request using a bucket that's already been locked

func (*Session) ServerGet

func (s *Session) ServerGet(serverID string) (*Server, error)

func (*Session) ServerMemberBan

func (s *Session) ServerMemberBan(serverID, userID string) (*ServerMemberBan, error)

ServerMemberBan returns a ban on a member of a server. serverID : The ID of a Server. userID : The ID of a User.

func (*Session) ServerMemberBanCreate

func (s *Session) ServerMemberBanCreate(serverID, userID, reason string) (*ServerMemberBan, error)

ServerMemberBanCreate creates a ban on a member of a server. serverID : The ID of a Server. userID : The ID of a User. reason : The reason for the ban.

func (*Session) ServerMemberBanDelete

func (s *Session) ServerMemberBanDelete(serverID, userID string) error

ServerMemberBanDelete deletes a ban on a member of a server. serverID : The ID of a Server. userID : The ID of a User.

func (*Session) ServerMemberBans

func (s *Session) ServerMemberBans(serverID string) ([]*ServerMemberBan, error)

ServerMemberBans returns an array of bans on a member of a server. serverID : The ID of a Server.

func (*Session) ServerMemberGet

func (s *Session) ServerMemberGet(serverID, userID string) (*ServerMember, error)

ServerMemberGet returns a member of the server. serverID : The ID of a Server. userID : The ID of a User.

func (*Session) ServerMemberKick

func (s *Session) ServerMemberKick(serverID, userID string) error

ServerMemberKick kicks a member from a server. serverID : The ID of a Server. userID : The ID of a User.

func (*Session) ServerMemberNicknameDelete

func (s *Session) ServerMemberNicknameDelete(serverID, userID string) error

ServerMemberNicknameDelete deletes a member's nickname in a server. serverID : The ID of a Server. userID : The ID of a User.

func (*Session) ServerMemberNicknameUpdate

func (s *Session) ServerMemberNicknameUpdate(serverID, userID string, nickname string) (string, error)

ServerMemberNicknameUpdate updates a member's nickname in a server. serverID : The ID of a Server. userID : The ID of a User. nickname : The nickname to set.

func (*Session) ServerMemberRoleAdd

func (s *Session) ServerMemberRoleAdd(serverID, memberID string, roleID int) error

ServerMemberRoleAdd adds a role to a member of a server. serverID : The ID of a Server. memberID : The ID of a Member. roleID : The ID of a Role.

func (*Session) ServerMemberRoleRemove

func (s *Session) ServerMemberRoleRemove(serverID, memberID string, roleID int) error

ServerMemberRoleRemove removes a role from a member of a server. serverID : The ID of a Server. memberID : The ID of a Member. roleID : The ID of a Role.

func (*Session) ServerMemberRoles

func (s *Session) ServerMemberRoles(serverID, memberID string) ([]int, error)

ServerMemberRoles returns a list of roles of a member of a server. serverID : The ID of a Server. memberID : The ID of a Member.

func (s *Session) ServerMemberSocialLink(serverID, memberID, linkType string) (*ServerSocialLink, error)

ServerMemberSocialLink returns a social link of a member of a server. serverID : The ID of a Server. memberID : The ID of a Member. linkType : The type of the social-link.

func (*Session) ServerMemberXPAward

func (s *Session) ServerMemberXPAward(serverID, memberID string, amount int) (int, error)

ServerMemberXPAward awards XP to a member of a server. serverID : The ID of a Server. memberID : The ID of a Member. amount : The amount of XP to award.

func (*Session) ServerMemberXPSet added in v0.3.4

func (s *Session) ServerMemberXPSet(serverID, memberID string, total int) (int, error)

ServerMemberXPSet sets role XP to a role of a server. serverID : The ID of a Server. memberID : The ID of a Member. total : The amount of XP set.

func (*Session) ServerMembers

func (s *Session) ServerMembers(serverID string) ([]*ServerMember, error)

ServerMembers returns an array of members of a server. serverID : The ID of a Server.

func (*Session) ServerRoleXPAward

func (s *Session) ServerRoleXPAward(serverID, roleID string, amount int) (int, error)

ServerRoleXPAward awards XP to a role of a server. serverID : The ID of a Server. roleID : The ID of a Role. amount : The amount of XP to award.

func (*Session) ServerWebhook

func (s *Session) ServerWebhook(serverID, webhookID string) (*Webhook, error)

ServerWebhook returns a webhook in a server. serverID : The ID of a Server. webhookID : The ID of a Webhook.

func (*Session) ServerWebhookCreate

func (s *Session) ServerWebhookCreate(serverID string, data *WebhookCreate) (*Webhook, error)

ServerWebhookCreate creates a webhook in a server. serverID : The ID of a Server. data : The data for the webhook.

func (*Session) ServerWebhookDelete

func (s *Session) ServerWebhookDelete(serverID, webhookID string) error

ServerWebhookDelete deletes a webhook in a server. serverID : The ID of a Server. webhookID : The ID of a Webhook.

func (*Session) ServerWebhookUpdate

func (s *Session) ServerWebhookUpdate(serverID, webhookID string, data *WebhookUpdate) (*Webhook, error)

ServerWebhookUpdate updates a webhook in a server. serverID : The ID of a Server. webhookID : The ID of a Webhook. data : The data for the webhook.

func (*Session) ServerWebhooks

func (s *Session) ServerWebhooks(serverID string) ([]*Webhook, error)

ServerWebhooks returns a list of webhooks in a server. serverID : The ID of a Server.

type TeamChannelCreated

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

type TeamChannelUpdated

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

type TeamMemberBanned

type TeamMemberBanned struct {
	ServerID        string          `json:"serverId"`
	ServerMemberBan ServerMemberBan `json:"serverMemberBan"`
}

type TeamMemberJoined

type TeamMemberJoined struct {
	ServerID string       `json:"serverId"`
	Member   ServerMember `json:"member"`
}

type TeamMemberRemoved

type TeamMemberRemoved struct {
	ServerID string `json:"serverId"`
	UserID   string `json:"userId"`
	IsKick   bool   `json:"isKick"`
	IsBan    bool   `json:"isBan"`
}

type TeamMemberUnbanned

type TeamMemberUnbanned struct {
	ServerID        string          `json:"serverId"`
	ServerMemberBan ServerMemberBan `json:"serverMemberBan"`
}

type TeamMemberUpdated

type TeamMemberUpdated struct {
	ServerID string   `json:"serverId"`
	UserInfo UserInfo `json:"userInfo"`
}

type TeamRolesUpdated

type TeamRolesUpdated struct {
	ServerID      string       `json:"serverId"`
	MemberRoleIds []MemberRole `json:"memberRoleIds"`
}

type TeamWebhookCreated

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

type TeamWebhookUpdated

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

type User

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

	// The type of the user
	// Can be "bot" or "user"
	Type string `json:"type"`

	// The name of the user
	Name string `json:"name"`

	// The avatar url of the user
	Avatar string `json:"avatar"`

	// The banner url of the user
	Banner string `json:"banner"`

	// The timestamp of when the user was created
	CreatedAt time.Time `json:"createdAt"`
}

User stores the data of a user.

func (*User) Mention

func (u *User) Mention() string

Mention returns a string that can be used to mention the user.

func (*User) MentionEmbed added in v0.1.1

func (u *User) MentionEmbed() string

MentionEmbed returns a string that can be used to mention the user in an embed.

type UserInfo

type UserInfo struct {
	ID       string `json:"id"`
	Nickname string `json:"nickname"`
}

type UserSummary

type UserSummary struct {
	ID     string `json:"id"`
	Type   string `json:"type"`
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
}

type UserType

type UserType string
const (
	UserTypeUser UserType = "user"
	UserTypeBot  UserType = "bot"
)

type Webhook

type Webhook struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	ServerId  string     `json:"serverId"`
	ChannelId string     `json:"channelId"`
	CreatedAt time.Time  `json:"createdAt"`
	CreatedBy string     `json:"createdBy"`
	DeletedAt *time.Time `json:"deletedAt"`
	Token     string     `json:"token"`
}

type WebhookCreate

type WebhookCreate struct {
	Name      string `json:"name" validate:"min=1,max=128"`
	ChannelID string `json:"channelId"`
}

WebhookCreate is the request body for creating a webhook

func (*WebhookCreate) Validate added in v0.1.1

func (w *WebhookCreate) Validate() error

Validate validates the webhook create request Returns nil if valid, otherwise returns an error

type WebhookUpdate

type WebhookUpdate struct {
	Name      string `json:"name" validate:"min=1,max=128"`
	ChannelID string `json:"channelId"`
}

WebhookUpdate is the request body for updating a webhook

func (*WebhookUpdate) Validate added in v0.1.1

func (w *WebhookUpdate) Validate() error

Validate validates the webhook update request Returns nil if valid, otherwise returns an error

Directories

Path Synopsis
examples
tools

Jump to

Keyboard shortcuts

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