Documentation
¶
Index ¶
- func SetInterval(someFunc func(), milliseconds int, async bool) chan bool
- func StartConnection(Response GatewayResponse, client *Client)
- type Channel
- type Client
- type ClientUser
- type Emoji
- type GatewayResponse
- type Guild
- type GuildMember
- type HeartbeatPacket
- type Permission
- type PermissionOverwrite
- type Presence
- type PresenceGame
- type RawPresence
- type Role
- type UnavailableGuild
- type User
- type VoiceState
- type WebSocketPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetInterval ¶
SetInterval repeats a task every x amount of miliseconds.
func StartConnection ¶
func StartConnection(Response GatewayResponse, client *Client)
StartConnection - initializes a new WebSocket connection.
Types ¶
type Channel ¶
type Channel struct {
ID string `json:"id"`
Type string `json:"type"`
GuildID string `json:"guild_id"`
Position int `json:"position"`
PermissionOverwrites []PermissionOverwrite `json:"this_is_for_style_purposes_only_:p"`
Name string `json:"name"`
Topic string `json:"topic"`
Nsfw bool `json:"nsfw"`
LastMessageID string `json:"last_message_id"`
Bitrate int `json:"bitrate"`
UserLimit int `json:"user_limit"`
Cooldown int `json:"rate_limit_per_user"`
Recipients []User `json:"recipients"`
Icon string `json:"icon"`
OwnerID string `json:"owner_id"`
ApplicationID string `json:"application_id"`
ParentID string `json:"parent_id"`
Client *Client
}
Channel - Represents a channel of a guild.
type Client ¶
type Client struct {
User ClientUser
HTTPClient *http.Client
Ws gowebsocket.Socket
Users map[string]User
Guilds map[string]Guild
Channels map[string]Channel
URL map[string]string
APIVersion string
Token string
Ready bool
Connected bool
LastHeartbeatSent int64
LastAckHeartbeat int64
LastSequenceNumber int
HeartbeatInterval chan bool
SessionID string
InitialGuilds []UnavailableGuild
Debug func(data string)
OnReady func()
}
Client - Client is the core class, starting point of any bot. Embeds {ClientUser}
func SpawnClient ¶
SpawnClient returns a freshly initialized empty client.
type ClientUser ¶
type ClientUser struct {
Avatar string `json:"avatar"`
Bot bool `json:"bot"`
Discriminator string `json:"discriminator"`
ID string `json:"id"`
Locale string `json:"locale"`
System bool `json:"system"`
Username string `json:"username"`
MfaEnabled bool `json:"mfa_enabled"`
Tag string
}
ClientUser holds the data of the user of the client.
func (*ClientUser) Instantiate ¶
func (clientUser *ClientUser) Instantiate()
Instantiate sets up properties after they've been received from discord.
type Emoji ¶
type Emoji struct {
ID string `json:"id"`
Name string `json:"name"`
User User `json:"user"`
RequireColons bool `json:"require_colons"`
Managed bool `json:"managed"`
Animated bool `json:"animated"`
Available bool `json:"available"`
Client *Client
}
Emoji - Holds an emoji's data.
func (*Emoji) Instantiate ¶
Instantiate instantiates an Emoji structure.
type GatewayResponse ¶
type GatewayResponse struct {
URL string `json:"url"`
Shards int `json:"shards"`
SessionLimit struct {
Total int `json:"total"`
Remaining int `json:"remaining"`
ResetAfter int `json:"reset_after"`
} `json:"session_start_limit"`
}
GatewayResponse holds the /gateway/bot response data.
type Guild ¶
type Guild struct {
ID string `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"`
Splash string `json:"splash"`
DiscoverySplash string `json:"discovery_splash"`
OwnerID string `json:"owner_id"`
Permissions int `json:"permissions"`
Region string `json:"region"`
AfkChannelID string `json:"afk_channel_id"`
AfkTimeout int `json:"afk_timeout"`
EmbedEnabled bool `json:"embed_enabled"`
EmbedChannelID string `json:"embed_channel_id"`
VerificationLevel int `json:"verification_level"`
DefaultMessageNotifications int `json:"default_message_notifications"`
ExplicitContentFilter int `json:"explicit_content_filter"`
Roles map[string]Role `json:"roles"`
Emojis map[string]Emoji `json:"emojis"`
Features []string `json:"features"`
MfaLevel int `json:"mfa_level"`
ApplicationID string `json:"application_id"`
WidgetEnabled bool `json:"widget_enabled"`
WidgetChannelID string `json:"widget_channel_id"`
SystemChannelID string `json:"system_channel_id"`
SystemChannelFlags int `json:"system_channel_flags"`
RulesChannelID string `json:"rules_channel_id"`
VoiceStates map[string]VoiceState `json:"voice_states"`
Members map[string]GuildMember `json:"members"`
Channels map[string]Channel `json:"this_tag_has_no_real_purpose"`
Large bool `json:"large"`
MemberCount int `json:"member_count"`
MaxPresences int `json:"max_presences"`
MaxMembers int `json:"max_members"`
VanityCode string `json:"vanity_url_code"`
Description string `json:"description"`
Banner string `json:"banner"`
PremiumTier int `json:"premium_tier"`
PremiumSubscriptionCount int `json:"premium_subscription_count"`
PreferredLocale string `json:"preferred_locale"`
PublicUpdatesChannelID string `json:"public_updates_channel_id"`
Client *Client
}
Guild - Represents data of a "discord server".
func (*Guild) Instantiate ¶
Instantiate instantiates a Guild structure.
type GuildMember ¶
type GuildMember struct {
User User `json:"user"`
Nickname string `json:"nick"`
Roles map[string]Role `json:"roles"`
Deaf bool `json:"deaf"`
Muted bool `json:"mute"`
}
GuildMember holds the data of a guild member.
type HeartbeatPacket ¶
HeartbeatPacket helps with serialization of the heartbeat packet.
type Permission ¶
Permission holds the bitfield and the permsissions included in it.
func CalculateBitfield ¶
func CalculateBitfield(bitfield int) Permission
CalculateBitfield returns the Permission interface for that bitfield.
type PermissionOverwrite ¶
type PermissionOverwrite struct {
ID string `json:"id"`
Type string `json:"type"`
Allow Permission `json:"allow"`
Deny Permission `json:"deny"`
Role Role
User User
}
PermissionOverwrite holds the data of a channel's permission overweries.
type Presence ¶
type Presence struct {
Status string
Game PresenceGame
}
Presence holds the presence data attached to User.
type PresenceGame ¶
type PresenceGame struct {
Name string `json:"name"`
Type int `json:"type"`
URL int `json:"url"`
CreatedAt int `json:"created_at"`
Timestamps struct {
Start int `json:"start"`
End int `json:"end"`
} `json:"timestamps"`
ApplicationID string `json:"application_id"`
Details string `json:"details"`
Status string `json:"state"`
Emoji struct {
Name string `json:"name"`
ID string `json:"id"`
Animated bool `json:"animated"`
} `json:"emoji"`
Party struct {
ID string `json:"id"`
Size []int `json:"size"`
} `json:"party"`
}
PresenceGame helds data of the game an user is playing.
type RawPresence ¶
type RawPresence struct {
User struct {
Avatar string `json:"avatar"`
Bot bool `json:"bot"`
Discriminator string `json:"discriminator"`
ID string `json:"id"`
Locale string `json:"locale"`
System bool `json:"system"`
Username string `json:"username"`
MfaEnabled bool `json:"mfa_enabled"`
} `json:"user"`
Roles []string `json:"roles"`
Game PresenceGame `json:"game"`
GuildID string `json:"guild_id"`
Status string `json:"status"`
Nick string `json:"nick"`
}
RawPresence used to serialize websocket JSON presence payload.
type Role ¶
type Role struct {
ID string `json:"id"`
Name string `json:"name"`
Color int `json:"color"`
Hoist bool `json:"hoist"`
Position int `json:"position"`
Permissions int `json:"permissions"`
Managed bool `json:"managed"`
Mentionable bool `json:"mentionable"`
Client *Client
}
Role - Holds the data of a role.
func (*Role) Instantiate ¶
Instantiate instantiates a Role structure.
type UnavailableGuild ¶
type UnavailableGuild struct {
}
UnavailableGuild holds data of an unavailable guild.
type User ¶
type User struct {
Avatar string `json:"avatar"`
Bot bool `json:"bot"`
Discriminator string `json:"discriminator"`
ID string `json:"id"`
Locale string `json:"locale"`
System bool `json:"system"`
Username string `json:"username"`
MfaEnabled bool `json:"mfa_enabled"`
Tag string
Client *Client
Presence Presence
}
User - Holds an user's data.
func (*User) Instantiate ¶
Instantiate instantiates an User structure.
type VoiceState ¶
type VoiceState struct {
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id"`
UserID string `json:"user_id"`
SessionID string `json:"session_id"`
Deaf bool `json:"deaf"`
Mute bool `json:"mute"`
SelfDeaf bool `json:"self_deaf"`
SelfMute bool `json:"self_mute"`
SelfStream bool `json:"self_stream"`
Suppress bool `json:"suppress"`
Client *Client
User User
Channel Channel
}
VoiceState - Holds a voice state's data.
func (*VoiceState) Instantiate ¶
func (state *VoiceState) Instantiate(client *Client)
Instantiate instantiates a VoiceState interface.
type WebSocketPayload ¶
type WebSocketPayload struct {
Op int `json:"op"`
Data struct {
HeartbeatInterval int `json:"heartbeat_interval"`
SessionID string `json:"session_id"`
GatewayVersion int `json:"v"`
User User `json:"user"`
PrivateChannels []string `json:"private_channels"`
Guilds []UnavailableGuild `json:"guilds"`
ID string `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"`
Splash string `json:"splash"`
DiscoverySplash string `json:"discovery_splash"`
OwnerID string `json:"owner_id"`
Permissions int `json:"permissions"`
Region string `json:"region"`
AfkChannelID string `json:"afk_channel_id"`
AfkTimeout int `json:"afk_timeout"`
EmbedEnabled bool `json:"embed_enabled"`
EmbedChannelID string `json:"embed_channel_id"`
VerificationLevel int `json:"verification_level"`
DefaultMessageNotifications int `json:"default_message_notifications"`
ExplicitContentFilter int `json:"explicit_content_filter"`
Roles []Role `json:"roles"`
Emojis []struct {
ID string `json:"id"`
Name string `json:"name"`
User struct {
Avatar string `json:"avatar"`
Bot bool `json:"bot"`
Discriminator string `json:"discriminator"`
ID string `json:"id"`
Locale string `json:"locale"`
System bool `json:"system"`
Username string `json:"username"`
MfaEnabled bool `json:"mfa_enabled"`
} `json:"user"`
RequireColons bool `json:"require_colons"`
Managed bool `json:"managed"`
Animated bool `json:"animated"`
Available bool `json:"available"`
} `json:"emojis"`
Channels []struct {
ID string `json:"id"`
Type int `json:"type"`
GuildID string `json:"guild_id"`
Position int `json:"position"`
Name string `json:"name"`
Topic string `json:"topic"`
Nsfw bool `json:"nsfw"`
LastMessageID string `json:"last_message_id"`
Bitrate int `json:"bitrate"`
UserLimit int `json:"user_limit"`
Cooldown int `json:"rate_limit_per_user"`
PermissionOverwrites []struct {
ID string `json:"id"`
Type string `json:"type"`
Allow int `json:"allow"`
Deny int `json:"deny"`
} `json:"permission_overwrites"`
Recipients []struct {
Avatar string `json:"avatar"`
Bot bool `json:"bot"`
Discriminator string `json:"discriminator"`
ID string `json:"id"`
Locale string `json:"locale"`
System bool `json:"system"`
Username string `json:"username"`
MfaEnabled bool `json:"mfa_enabled"`
Tag string
} `json:"recipients"`
Icon string `json:"icon"`
OwnerID string `json:"owner_id"`
ApplicationID string `json:"application_id"`
ParentID string `json:"parent_id"`
}
Features []string `json:"features"`
MfaLevel int `json:"mfa_level"`
ApplicationID string `json:"application_id"`
WidgetEnabled bool `json:"widget_enabled"`
WidgetChannelID string `json:"widget_channel_id"`
SystemChannelID string `json:"system_channel_id"`
SystemChannelFlags int `json:"system_channel_flags"`
RulesChannelID string `json:"rules_channel_id"`
VoiceStates []struct {
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id"`
UserID string `json:"user_id"`
SessionID string `json:"session_id"`
Deaf bool `json:"deaf"`
Mute bool `json:"mute"`
SelfDeaf bool `json:"self_deaf"`
SelfMute bool `json:"self_mute"`
SelfStream bool `json:"self_stream"`
Suppress bool `json:"suppress"`
} `json:"voice_states"`
Presences []RawPresence `json:"presences"`
Members []struct {
User struct {
Avatar string `json:"avatar"`
Bot bool `json:"bot"`
Discriminator string `json:"discriminator"`
ID string `json:"id"`
Locale string `json:"locale"`
System bool `json:"system"`
Username string `json:"username"`
MfaEnabled bool `json:"mfa_enabled"`
Tag string
} `json:"user"`
Nickname string `json:"nick"`
Roles []string `json:"roles"`
Deaf bool `json:"deaf"`
Muted bool `json:"mute"`
} `json:"members"`
Large bool `json:"large"`
Unavailable bool `json:"unavailable"`
MemberCount int `json:"member_count"`
MaxPresences int `json:"max_presences"`
MaxMembers int `json:"max_members"`
VanityCode string `json:"vanity_url_code"`
Description string `json:"description"`
Banner string `json:"banner"`
PremiumTier int `json:"premium_tier"`
PremiumSubscriptionCount int `json:"premium_subscription_count"`
PreferredLocale string `json:"preferred_locale"`
PublicUpdatesChannelID string `json:"public_updates_channel_id"`
} `json:"d"`
SequenceNumber int `json:"s"`
Event string `json:"t"`
}
WebSocketPayload helps deserialize json websocket events.