123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527 |
- package discordgo
- import (
- "encoding/json"
- "reflect"
- "sync"
- "time"
- "github.com/gorilla/websocket"
- )
- type Session struct {
- sync.RWMutex
-
-
- Token string
-
- Debug bool
- LogLevel int
-
- ShouldReconnectOnError bool
-
- Compress bool
-
- ShardID int
- ShardCount int
-
-
-
- StateEnabled bool
-
-
- DataReady bool
-
-
- status int32
-
- VoiceReady bool
-
- UDPReady bool
-
- VoiceConnections map[string]*VoiceConnection
-
-
- State *State
- handlersMu sync.RWMutex
-
-
-
-
-
- handlers map[interface{}][]reflect.Value
-
- wsConn *websocket.Conn
-
- listening chan interface{}
-
-
-
- rateLimit rateLimitMutex
-
- sequence int
-
- gateway string
-
- sessionID string
-
- wsMutex sync.Mutex
- }
- type rateLimitMutex struct {
- sync.Mutex
- url map[string]*sync.Mutex
-
- }
- type Resumed struct {
- HeartbeatInterval time.Duration `json:"heartbeat_interval"`
- Trace []string `json:"_trace"`
- }
- type VoiceRegion struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Hostname string `json:"sample_hostname"`
- Port int `json:"sample_port"`
- }
- type VoiceICE struct {
- TTL string `json:"ttl"`
- Servers []*ICEServer `json:"servers"`
- }
- type ICEServer struct {
- URL string `json:"url"`
- Username string `json:"username"`
- Credential string `json:"credential"`
- }
- type Invite struct {
- Guild *Guild `json:"guild"`
- Channel *Channel `json:"channel"`
- Inviter *User `json:"inviter"`
- Code string `json:"code"`
- CreatedAt string `json:"created_at"`
- MaxAge int `json:"max_age"`
- Uses int `json:"uses"`
- MaxUses int `json:"max_uses"`
- XkcdPass string `json:"xkcdpass"`
- Revoked bool `json:"revoked"`
- Temporary bool `json:"temporary"`
- }
- type Channel struct {
- ID string `json:"id"`
- GuildID string `json:"guild_id"`
- Name string `json:"name"`
- Topic string `json:"topic"`
- Type string `json:"type"`
- LastMessageID string `json:"last_message_id"`
- Position int `json:"position"`
- Bitrate int `json:"bitrate"`
- IsPrivate bool `json:"is_private"`
- Recipient *User `json:"recipient"`
- Messages []*Message `json:"-"`
- PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites"`
- }
- type PermissionOverwrite struct {
- ID string `json:"id"`
- Type string `json:"type"`
- Deny int `json:"deny"`
- Allow int `json:"allow"`
- }
- type Emoji struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Roles []string `json:"roles"`
- Managed bool `json:"managed"`
- RequireColons bool `json:"require_colons"`
- }
- type VerificationLevel int
- const (
- VerificationLevelNone VerificationLevel = iota
- VerificationLevelLow
- VerificationLevelMedium
- VerificationLevelHigh
- )
- type Guild struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Icon string `json:"icon"`
- Region string `json:"region"`
- AfkChannelID string `json:"afk_channel_id"`
- EmbedChannelID string `json:"embed_channel_id"`
- OwnerID string `json:"owner_id"`
- JoinedAt string `json:"joined_at"`
- Splash string `json:"splash"`
- AfkTimeout int `json:"afk_timeout"`
- VerificationLevel VerificationLevel `json:"verification_level"`
- EmbedEnabled bool `json:"embed_enabled"`
- Large bool `json:"large"`
- DefaultMessageNotifications int `json:"default_message_notifications"`
- Roles []*Role `json:"roles"`
- Emojis []*Emoji `json:"emojis"`
- Members []*Member `json:"members"`
- Presences []*Presence `json:"presences"`
- Channels []*Channel `json:"channels"`
- VoiceStates []*VoiceState `json:"voice_states"`
- Unavailable *bool `json:"unavailable"`
- }
- type GuildParams struct {
- Name string `json:"name"`
- Region string `json:"region"`
- VerificationLevel *VerificationLevel `json:"verification_level"`
- }
- type Role struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Managed bool `json:"managed"`
- Hoist bool `json:"hoist"`
- Color int `json:"color"`
- Position int `json:"position"`
- Permissions int `json:"permissions"`
- }
- type VoiceState struct {
- UserID string `json:"user_id"`
- SessionID string `json:"session_id"`
- ChannelID string `json:"channel_id"`
- GuildID string `json:"guild_id"`
- Suppress bool `json:"suppress"`
- SelfMute bool `json:"self_mute"`
- SelfDeaf bool `json:"self_deaf"`
- Mute bool `json:"mute"`
- Deaf bool `json:"deaf"`
- }
- type Presence struct {
- User *User `json:"user"`
- Status string `json:"status"`
- Game *Game `json:"game"`
- }
- type Game struct {
- Name string `json:"name"`
- Type int `json:"type"`
- URL string `json:"url"`
- }
- type Member struct {
- GuildID string `json:"guild_id"`
- JoinedAt string `json:"joined_at"`
- Nick string `json:"nick"`
- Deaf bool `json:"deaf"`
- Mute bool `json:"mute"`
- User *User `json:"user"`
- Roles []string `json:"roles"`
- }
- type User struct {
- ID string `json:"id"`
- Email string `json:"email"`
- Username string `json:"username"`
- Avatar string `json:"Avatar"`
- Discriminator string `json:"discriminator"`
- Token string `json:"token"`
- Verified bool `json:"verified"`
- MFAEnabled bool `json:"mfa_enabled"`
- Bot bool `json:"bot"`
- }
- type Settings struct {
- RenderEmbeds bool `json:"render_embeds"`
- InlineEmbedMedia bool `json:"inline_embed_media"`
- InlineAttachmentMedia bool `json:"inline_attachment_media"`
- EnableTtsCommand bool `json:"enable_tts_command"`
- MessageDisplayCompact bool `json:"message_display_compact"`
- ShowCurrentGame bool `json:"show_current_game"`
- AllowEmailFriendRequest bool `json:"allow_email_friend_request"`
- ConvertEmoticons bool `json:"convert_emoticons"`
- Locale string `json:"locale"`
- Theme string `json:"theme"`
- GuildPositions []string `json:"guild_positions"`
- RestrictedGuilds []string `json:"restricted_guilds"`
- FriendSourceFlags *FriendSourceFlags `json:"friend_source_flags"`
- }
- type FriendSourceFlags struct {
- All bool `json:"all"`
- MutualGuilds bool `json:"mutual_guilds"`
- MutualFriends bool `json:"mutual_friends"`
- }
- type Event struct {
- Operation int `json:"op"`
- Sequence int `json:"s"`
- Type string `json:"t"`
- RawData json.RawMessage `json:"d"`
- Struct interface{} `json:"-"`
- }
- type Ready struct {
- Version int `json:"v"`
- SessionID string `json:"session_id"`
- HeartbeatInterval time.Duration `json:"heartbeat_interval"`
- User *User `json:"user"`
- ReadState []*ReadState `json:"read_state"`
- PrivateChannels []*Channel `json:"private_channels"`
- Guilds []*Guild `json:"guilds"`
-
- Settings *Settings `json:"user_settings"`
- UserGuildSettings []*UserGuildSettings `json:"user_guild_settings"`
- Relationships []*Relationship `json:"relationships"`
- Presences []*Presence `json:"presences"`
- }
- type Relationship struct {
- User *User `json:"user"`
- Type int `json:"type"`
- ID string `json:"id"`
- }
- type TooManyRequests struct {
- Bucket string `json:"bucket"`
- Message string `json:"message"`
- RetryAfter time.Duration `json:"retry_after"`
- }
- type ReadState struct {
- MentionCount int `json:"mention_count"`
- LastMessageID string `json:"last_message_id"`
- ID string `json:"id"`
- }
- type TypingStart struct {
- UserID string `json:"user_id"`
- ChannelID string `json:"channel_id"`
- Timestamp int `json:"timestamp"`
- }
- type PresenceUpdate struct {
- Presence
- GuildID string `json:"guild_id"`
- Roles []string `json:"roles"`
- }
- type MessageAck struct {
- MessageID string `json:"message_id"`
- ChannelID string `json:"channel_id"`
- }
- type GuildIntegrationsUpdate struct {
- GuildID string `json:"guild_id"`
- }
- type GuildRole struct {
- Role *Role `json:"role"`
- GuildID string `json:"guild_id"`
- }
- type GuildRoleDelete struct {
- RoleID string `json:"role_id"`
- GuildID string `json:"guild_id"`
- }
- type GuildBan struct {
- User *User `json:"user"`
- GuildID string `json:"guild_id"`
- }
- type GuildEmojisUpdate struct {
- GuildID string `json:"guild_id"`
- Emojis []*Emoji `json:"emojis"`
- }
- type GuildIntegration struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Type string `json:"type"`
- Enabled bool `json:"enabled"`
- Syncing bool `json:"syncing"`
- RoleID string `json:"role_id"`
- ExpireBehavior int `json:"expire_behavior"`
- ExpireGracePeriod int `json:"expire_grace_period"`
- User *User `json:"user"`
- Account *GuildIntegrationAccount `json:"account"`
- SyncedAt int `json:"synced_at"`
- }
- type GuildIntegrationAccount struct {
- ID string `json:"id"`
- Name string `json:"name"`
- }
- type GuildEmbed struct {
- Enabled bool `json:"enabled"`
- ChannelID string `json:"channel_id"`
- }
- type UserGuildSettingsChannelOverride struct {
- Muted bool `json:"muted"`
- MessageNotifications int `json:"message_notifications"`
- ChannelID string `json:"channel_id"`
- }
- type UserGuildSettings struct {
- SupressEveryone bool `json:"suppress_everyone"`
- Muted bool `json:"muted"`
- MobilePush bool `json:"mobile_push"`
- MessageNotifications int `json:"message_notifications"`
- GuildID string `json:"guild_id"`
- ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
- }
- type UserGuildSettingsEdit struct {
- SupressEveryone bool `json:"suppress_everyone"`
- Muted bool `json:"muted"`
- MobilePush bool `json:"mobile_push"`
- MessageNotifications int `json:"message_notifications"`
- ChannelOverrides map[string]*UserGuildSettingsChannelOverride `json:"channel_overrides"`
- }
- type ChannelPinsUpdate struct {
- LastPinTimestamp string `json:"last_pin_timestamp"`
- ChannelID string `json:"channel_id"`
- }
- const (
- PermissionReadMessages = 1 << (iota + 10)
- PermissionSendMessages
- PermissionSendTTSMessages
- PermissionManageMessages
- PermissionEmbedLinks
- PermissionAttachFiles
- PermissionReadMessageHistory
- PermissionMentionEveryone
- )
- const (
- PermissionVoiceConnect = 1 << (iota + 20)
- PermissionVoiceSpeak
- PermissionVoiceMuteMembers
- PermissionVoiceDeafenMembers
- PermissionVoiceMoveMembers
- PermissionVoiceUseVAD
- )
- const (
- PermissionCreateInstantInvite = 1 << iota
- PermissionKickMembers
- PermissionBanMembers
- PermissionManageRoles
- PermissionManageChannels
- PermissionManageServer
- PermissionAllText = PermissionReadMessages |
- PermissionSendMessages |
- PermissionSendTTSMessages |
- PermissionManageMessages |
- PermissionEmbedLinks |
- PermissionAttachFiles |
- PermissionReadMessageHistory |
- PermissionMentionEveryone
- PermissionAllVoice = PermissionVoiceConnect |
- PermissionVoiceSpeak |
- PermissionVoiceMuteMembers |
- PermissionVoiceDeafenMembers |
- PermissionVoiceMoveMembers |
- PermissionVoiceUseVAD
- PermissionAllChannel = PermissionAllText |
- PermissionAllVoice |
- PermissionCreateInstantInvite |
- PermissionManageRoles |
- PermissionManageChannels
- PermissionAll = PermissionAllChannel |
- PermissionKickMembers |
- PermissionBanMembers |
- PermissionManageServer
- )
|