Documentation
¶
Index ¶
- Constants
- Variables
- type APIErrorMessage
- type BotUser
- type CalendarEvent
- type CalendarEventCreated
- type CalendarEventDeleted
- type CalendarEventUpdated
- type Cancellation
- type ChannelCreate
- type ChannelDoc
- type ChannelEvent
- type ChannelEventsRequest
- type ChannelForumTopicCreate
- type ChannelListItem
- type ChannelListItemNote
- type ChannelMessageReactionCreated
- type ChannelMessageReactionDeleted
- type ChannelUpdate
- type ChatEmbed
- type ChatEmbedAuthor
- type ChatEmbedField
- type ChatEmbedFooter
- type ChatEmbedImage
- type ChatEmbedThumbnail
- type ChatMessage
- type ChatMessageCreated
- type ChatMessageDeleted
- type ChatMessageUpdated
- type Connect
- type Disconnect
- type Doc
- type DocCreated
- type DocDeleted
- type DocUpdated
- type Emote
- type Event
- type EventHandler
- type EventInterfaceProvider
- type ForumTopic
- type ListItem
- type ListItemCompleted
- type ListItemCreated
- type ListItemDeleted
- type ListItemNote
- type ListItemUpdated
- type MemberRole
- type MentionChannel
- type MentionRole
- type MentionUser
- type Mentions
- type MessageCreate
- type MessageType
- type MessageUpdate
- type MessagesRequest
- type RESTError
- type RateLimit
- type RateLimitError
- type Reaction
- type Ready
- type Server
- type ServerChannel
- type ServerChannelType
- type ServerMember
- type ServerMemberBan
- type ServerMemberBanCreate
- type ServerMemberNicknameUpdate
- type ServerSocialLink
- type ServerType
- type ServerXPUpdate
- type Session
- func (s *Session) AddHandler(handler interface{}) func()
- func (s *Session) AddHandlerOnce(handler interface{}) func()
- func (s *Session) ChannelContentReactionAdd(channelID, contentID string, emoteID int) error
- func (s *Session) ChannelContentReactionDelete(channelID, contentID string, emoteID int) error
- func (s *Session) ChannelCreate(data *ChannelCreate) (*ServerChannel, error)
- func (s *Session) ChannelDelete(channelID string) error
- func (s *Session) ChannelDoc(channelID string, docID int) (*Doc, error)
- func (s *Session) ChannelDocCreate(channelID string, data *ChannelDoc) (*Doc, error)
- func (s *Session) ChannelDocDelete(channelID string, docID int) error
- func (s *Session) ChannelDocUpdate(channelID string, docID int, data *ChannelDoc) (*Doc, error)
- func (s *Session) ChannelDocs(channelID string) ([]*Doc, error)
- func (s *Session) ChannelEvent(channelID string, eventID int) (*CalendarEvent, error)
- func (s *Session) ChannelEventCreate(channelID string, data *ChannelEvent) (*CalendarEvent, error)
- func (s *Session) ChannelEventDelete(channelID string, eventID int) error
- func (s *Session) ChannelEventUpdate(channelID string, eventID int, data *ChannelEvent) (*CalendarEvent, error)
- func (s *Session) ChannelEvents(channelID string, data *ChannelEventsRequest) ([]*CalendarEvent, error)
- func (s *Session) ChannelForumTopicCreate(channelID, title, content string) (*ForumTopic, error)
- func (s *Session) ChannelGet(channelID string) (*ServerChannel, error)
- func (s *Session) ChannelListItem(channelID, itemID string) (*ListItem, error)
- func (s *Session) ChannelListItemComplete(channelID, itemID string) error
- func (s *Session) ChannelListItemCreate(channelID string, data *ChannelListItem) (*ListItem, error)
- func (s *Session) ChannelListItemDelete(channelID, itemID string) error
- func (s *Session) ChannelListItemUncomplete(channelID, itemID string) error
- func (s *Session) ChannelListItemUpdate(channelID, itemID string, data *ChannelListItem) (*ListItem, error)
- func (s *Session) ChannelListItems(channelID string) ([]*ListItem, error)
- func (s *Session) ChannelMessage(channelID string, messageID string) (*ChatMessage, error)
- func (s *Session) ChannelMessageCreate(channelID string, content string) (*ChatMessage, error)
- func (s *Session) ChannelMessageCreateComplex(channelID string, data *MessageCreate) (st *ChatMessage, err error)
- func (s *Session) ChannelMessageDelete(channelID, messageID string) error
- func (s *Session) ChannelMessageUpdate(channelID, messageID string, data *MessageUpdate) (*ChatMessage, error)
- func (s *Session) ChannelMessages(channelID string, limit int, beforeTime, afterTime *time.Time, ...) ([]*ChatMessage, error)
- func (s *Session) ChannelUpdate(channelID string, data *ChannelUpdate) (*ServerChannel, error)
- func (s *Session) Close() error
- func (s *Session) CloseWithCode(closeCode int) (err error)
- func (s *Session) GroupMemberAdd(groupID, userID string) error
- func (s *Session) GroupMemberRemove(groupID, userID string) error
- func (s *Session) Open() error
- func (s *Session) Request(method, urlStr string, data interface{}) (response []byte, err error)
- func (s *Session) RequestCall(method, urlStr, contentType string, b []byte, sequence int) (response []byte, err error)
- func (s *Session) ServerGet(serverID string) (*Server, error)
- func (s *Session) ServerMemberBan(serverID, userID string) (*ServerMemberBan, error)
- func (s *Session) ServerMemberBanCreate(serverID, userID, reason string) (*ServerMemberBan, error)
- func (s *Session) ServerMemberBanDelete(serverID, userID string) error
- func (s *Session) ServerMemberBans(serverID string) ([]*ServerMemberBan, error)
- func (s *Session) ServerMemberGet(serverID, userID string) (*ServerMember, error)
- func (s *Session) ServerMemberKick(serverID, userID string) error
- func (s *Session) ServerMemberNicknameDelete(serverID, userID string) error
- func (s *Session) ServerMemberNicknameUpdate(serverID, userID string, nickname string) (string, error)
- func (s *Session) ServerMemberRoleAdd(serverID, memberID string, roleID int) error
- func (s *Session) ServerMemberRoleRemove(serverID, memberID string, roleID int) error
- func (s *Session) ServerMemberRoles(serverID, memberID string) ([]int, error)
- func (s *Session) ServerMemberSocialLink(serverID, memberID, linkType string) (*ServerSocialLink, error)
- func (s *Session) ServerMemberXPAward(serverID, memberID string, amount int) (int, error)
- func (s *Session) ServerMembers(serverID string) ([]*ServerMember, error)
- func (s *Session) ServerRoleXPAward(serverID, roleID string, amount int) (int, error)
- func (s *Session) ServerWebhook(serverID, webhookID string) (*Webhook, error)
- func (s *Session) ServerWebhookCreate(serverID string, data *WebhookCreate) (*Webhook, error)
- func (s *Session) ServerWebhookDelete(serverID, webhookID string) error
- func (s *Session) ServerWebhookUpdate(serverID, webhookID string, data *WebhookUpdate) (*Webhook, error)
- func (s *Session) ServerWebhooks(serverID string) ([]*Webhook, error)
- type TeamChannelCreated
- type TeamChannelUpdated
- type TeamMemberBanned
- type TeamMemberJoined
- type TeamMemberRemoved
- type TeamMemberUnbanned
- type TeamMemberUpdated
- type TeamRolesUpdated
- type TeamWebhookCreated
- type TeamWebhookUpdated
- type Timestamp
- type User
- type UserInfo
- type UserSummary
- type UserType
- type Webhook
- type WebhookCreate
- type WebhookUpdate
Constants ¶
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 )
const FailedHeartbeatAcks time.Duration = 5 * time.Millisecond
FailedHeartbeatAcks is the Number of heartbeat intervals to wait until forcing a connection restart.
const VERSION = "0.1.0"
VERSION of Guildrone, follows Semantic Versioning. (http://semver.org/)
Variables ¶
var ( APIVersion = "1" EndpointGuildedWebsocket = "wss://api.guilded.gg/v1/websocket" 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" } 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 } 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 } )
var ( ErrJSONUnmarshal = errors.New("json unmarshal") ErrStatusOffline = errors.New("You can't set your Status to offline") ErrVerificationLevelBounds = errors.New("VerificationLevel out of bounds, should be between 0 and 3") ErrPruneDaysBounds = errors.New("the number of days should be more than or equal to 1") ErrGuildNoIcon = errors.New("guild does not have an icon set") ErrGuildNoSplash = errors.New("guild does not have a splash set") )
All error constants
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 )
var ErrWSAlreadyOpen = errors.New("web socket already opened")
ErrWSAlreadyOpen is thrown when you attempt to open a websocket that already is open.
var ErrWSNotFound = errors.New("no websocket connection exists")
ErrWSNotFound is thrown when you attempt to use a websocket that doesn't exist
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 ¶
An APIErrorMessage is an api error message returned from Guilded
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 Timestamp `json:"startsAt"`
// Duration in minutes
Duration int `json:"duration"`
IsPrivate bool `json:"isPrivate"`
Mentions *Mentions `json:"mentions"`
CreatedAt Timestamp `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 CalendarEventUpdated ¶
type CalendarEventUpdated struct {
ServerID string `json:"serverId"`
CalendarEvent CalendarEvent `json:"calendarEvent"`
}
type Cancellation ¶
type ChannelCreate ¶
type ChannelCreate struct {
Name string `json:"name"`
Topic string `json:"topic,omitempty"`
IsPublic bool `json:"isPublic,omitempty"`
Type ServerChannelType `json:"type"`
ServerID string `json:"serverId,omitempty"`
GroupID string `json:"groupId,omitempty"`
CategoryID string `json:"categoryId,omitempty"`
}
type ChannelDoc ¶
type ChannelEvent ¶
type ChannelEvent struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Location string `json:"location,omitempty"`
StartsAt *Timestamp `json:"startsAt,omitempty"`
URL string `json:"url,omitempty"`
Color int `json:"color,omitempty"`
Duration int `json:"duration,omitempty"`
IsPrivate bool `json:"isPrivate,omitempty"`
}
type ChannelEventsRequest ¶
type ChannelForumTopicCreate ¶
type ChannelListItem ¶
type ChannelListItem struct {
Message string `json:"message"`
Note *ChannelListItemNote `json:"note,omitempty"`
}
type ChannelListItemNote ¶
type ChannelListItemNote struct {
Content string `json:"content"`
}
type ChannelUpdate ¶
type ChatEmbed ¶
type ChatEmbed struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
URL string `json:"url,omitempty"`
Color int `json:"color"`
Timestamp *Timestamp `json:"timestamp,omitempty"`
Thumbnail *ChatEmbedThumbnail `json:"thumbnail,omitempty"`
Image *ChatEmbedImage `json:"image,omitempty"`
Author *ChatEmbedAuthor `json:"author,omitempty"`
Fields []ChatEmbedField `json:"fields,omitempty"`
}
type ChatEmbedAuthor ¶
type ChatEmbedField ¶
type ChatEmbedFooter ¶
type ChatEmbedFooter struct {
}
type ChatEmbedImage ¶
type ChatEmbedImage struct {
URL string `json:"url,omitempty"`
}
type ChatEmbedThumbnail ¶
type ChatEmbedThumbnail struct {
URL string `json:"url,omitempty"`
}
type ChatMessage ¶
type ChatMessage struct {
// The ID of the message
ID string `json:"id"`
// Type of the message
Type MessageType `json:"type"`
// The ID of the server the message was sent in
ServerID string `json:"serverId"`
// The ID of the channel the message was sent in
ChannelID string `json:"channelId"`
// Content of the message
Content string `json:"content"`
// Embedded content
Embeds []ChatEmbed `json:"embeds"`
// Message ids that were replied to
ReplyMessageIds []string `json:"replyMessageIds"`
// If set, this message will only be seen by those mentioned or replied to
IsPrivate bool `json:"isPrivate"`
IsSilent bool `json:"isSilent"`
Mentions *Mentions `json:"mentions,omitempty"`
CreatedAt string `json:"createdAt"`
CreatedBy string `json:"createdBy"`
CreatedByWebhookId string `json:"createdByWebhookId"`
UpdatedAt *Timestamp `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 Timestamp `json:"createdAt"`
CreatedBy string `json:"createdBy"`
UpdatedAt *Timestamp `json:"updatedAt"`
UpdatedBy string `json:"updatedBy"`
}
type DocCreated ¶
type DocDeleted ¶
type DocUpdated ¶
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 Timestamp `json:"createdAt"`
CreatedBy string `json:"createdBy"`
CreatedByWebhookId string `json:"createdByWebhookId,omitempty"`
UpdatedAt *Timestamp `json:"updatedAt,omitempty"`
}
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 Timestamp `json:"createdAt"`
CreatedBy string `json:"createdBy"`
CreatedByWebhookId string `json:"createdByWebhookId"`
UpdatedAt *Timestamp `json:"updatedAt"`
UpdatedBy string `json:"updatedBy"`
ParentListItemId string `json:"parentListItemId"`
CompletedAt string `json:"completedAt"`
CompletedBy string `json:"completedBy"`
Note *ListItemNote `json:"note"`
}
type ListItemCompleted ¶
type ListItemCreated ¶
type ListItemDeleted ¶
type ListItemNote ¶
type ListItemUpdated ¶
type MemberRole ¶
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"`
Channels []MentionChannel `json:"channels,omitempty"`
Roles []MentionRole `json:"roles,omitempty"`
Everyone bool `json:"everyone,omitempty"`
Here bool `json:"here,omitempty"`
}
type MessageCreate ¶
type MessageType ¶
type MessageType string
const ( MessageTypeDefault MessageType = "default" MessageTypeSystem MessageType = "system" )
type MessageUpdate ¶
type MessagesRequest ¶
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.
type RateLimit ¶
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 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"`
DefaultChannleID string `json:"defaultChannelId,omitempty"`
CreatedAt Timestamp `json:"createdAt"`
}
type ServerChannel ¶
type ServerChannel struct {
ID string `json:"id"`
Type ServerChannelType `json:"type"`
Name string `json:"name"`
Topic string `json:"topic"`
CreatedAt Timestamp `json:"createdAt"`
CreatedBy string `json:"createdBy"`
UpdatedAt *Timestamp `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 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 ServerMember ¶
type ServerMemberBan ¶
type ServerMemberBan struct {
UserSummary UserSummary `json:"user"`
Reason string `json:"reason"`
CreatedBy string `json:"createdBy"`
CreatedAt Timestamp `json:"createdAt"`
}
type ServerMemberBanCreate ¶
type ServerMemberBanCreate struct {
Reason string `json:"reason"`
}
type ServerMemberNicknameUpdate ¶
type ServerMemberNicknameUpdate struct {
Nickname string `json:"nickname"`
}
type ServerSocialLink ¶
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 ServerXPUpdate ¶
type ServerXPUpdate struct {
Amount int `json:"amount"`
}
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
// 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 (*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 ¶
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 ¶
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 *ChannelCreate) (*ServerChannel, error)
ChannelCreate creates a channel in a server. data : The channel struct to send.
func (*Session) ChannelDelete ¶
ChannelDelete deletes a channel. channelID : The ID of a Channel.
func (*Session) ChannelDoc ¶
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 ¶
ChannelDocDelete deletes a doc in a channel. channelID : The ID of a Channel. docID : The ID of a Doc.
func (*Session) ChannelDocUpdate ¶
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 ¶
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 ¶
ChannelEventDelete deletes a calendar event 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, data *ChannelEventsRequest) ([]*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) 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) ChannelGet ¶
func (s *Session) ChannelGet(channelID string) (*ServerChannel, error)
ChannelGet returns a channel. channelID : The ID of a Channel.
func (*Session) ChannelListItem ¶
ChannelListItem returns a list item in a channel. channelID : The ID of a Channel. itemID : The ID of a ListItem.
func (*Session) ChannelListItemComplete ¶
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)
ChannelListItem creates a list item in a channel. channelID : The ID of a Channel. data : The data for the list item.
func (*Session) ChannelListItemDelete ¶
ChannelListItemDelete deletes a list item in a channel. channelID : The ID of a Channel. itemID : The ID of a ListItem.
func (*Session) ChannelListItemUncomplete ¶
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 ¶
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 ¶
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 *ChannelUpdate) (*ServerChannel, error)
ChannelUpdate updates a channel. channelID : The ID of a Channel. data : The channel struct to send.
func (*Session) CloseWithCode ¶
CloseWithCode closes a websocket using the provided closeCode and stops all listening/heartbeat goroutines.
func (*Session) GroupMemberAdd ¶
GroupMemberAdd adds a member to a group. groupID : The ID of a Group. memberID : The ID of a Member.
func (*Session) GroupMemberRemove ¶
GroupMemberRemove removes a member from a group. groupID : The ID of a Group. memberID : The ID of a Member.
func (*Session) Open ¶
Open creates a websocket connection to Guilded. See: https://www.guilded.gg/docs/api/connecting
func (*Session) Request ¶
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) 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 ¶
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 ¶
ServerMemberKick kicks a member from a server. serverID : The ID of a Server. userID : The ID of a User.
func (*Session) ServerMemberNicknameDelete ¶
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 ¶
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 ¶
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 ¶
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 (*Session) ServerMemberSocialLink ¶
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 ¶
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) 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 ¶
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 ¶
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 (*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.
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 TeamMemberUnbanned ¶
type TeamMemberUnbanned struct {
ServerID string `json:"serverId"`
ServerMemberBan ServerMemberBan `json:"serverMemberBan"`
}
type TeamMemberUpdated ¶
type TeamRolesUpdated ¶
type TeamRolesUpdated struct {
ServerID string `json:"serverId"`
MemberRoleIds []MemberRole `json:"memberRoleIds"`
}
type TeamWebhookCreated ¶
type TeamWebhookUpdated ¶
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 Timestamp `json:"createdAt"`
}
User stores the data of a user.