-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor fixes, undocumented things, and editorconfig
- Loading branch information
1 parent
ce0bd07
commit ac685b0
Showing
9 changed files
with
249 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[.gitlab-ci.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package api | ||
|
||
import "github.com/diamondburned/arikawa/internal/httputil" | ||
|
||
const ( | ||
EndpointAuth = Endpoint + "auth/" | ||
EndpointLogin = EndpointAuth + "login" | ||
EndpointTOTP = EndpointAuth + "mfa/totp" | ||
) | ||
|
||
type LoginResponse struct { | ||
MFA bool `json:"mfa"` | ||
SMS bool `json:"sms"` | ||
Ticket string `json:"ticket"` | ||
Token string `json:"token"` | ||
} | ||
|
||
func (c *Client) Login(email, password string) (*LoginResponse, error) { | ||
var param struct { | ||
Email string `json:"email"` | ||
Password string `json:"password"` | ||
} | ||
param.Email = email | ||
param.Password = password | ||
|
||
var r *LoginResponse | ||
return r, c.RequestJSON(&r, "POST", EndpointLogin, | ||
httputil.WithJSONBody(c, param)) | ||
} | ||
|
||
func (c *Client) TOTP(code, ticket string) (*LoginResponse, error) { | ||
var param struct { | ||
Code string `json:"code"` | ||
Ticket string `json:"ticket"` | ||
} | ||
param.Code = code | ||
param.Ticket = ticket | ||
|
||
var r *LoginResponse | ||
return r, c.RequestJSON(&r, "POST", EndpointTOTP, | ||
httputil.WithJSONBody(c, param)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package gateway | ||
|
||
import "github.com/diamondburned/arikawa/discord" | ||
|
||
type ReadyEvent struct { | ||
Version int `json:"version"` | ||
|
||
User discord.User `json:"user"` | ||
SessionID string `json:"session_id"` | ||
|
||
PrivateChannels []discord.Channel `json:"private_channels"` | ||
Guilds []discord.Guild `json:"guilds"` | ||
|
||
Shard *Shard `json:"shard"` | ||
|
||
// Undocumented fields | ||
Settings *UserSettings `json:"user_settings"` | ||
UserGuildSettings []UserGuildSettings `json:"user_guild_settings"` | ||
Relationships []Relationship `json:"relationships"` | ||
Presences []discord.Presence `json:"presences,omitempty"` | ||
Notes map[discord.Snowflake]string `json:"notes,omitempty"` | ||
} | ||
|
||
type UserSettings struct { | ||
ShowCurrentGame bool `json:"show_current_game"` | ||
DefaultGuildsRestricted bool `json:"default_guilds_restricted"` | ||
InlineAttachmentMedia bool `json:"inline_attachment_media"` | ||
InlineEmbedMedia bool `json:"inline_embed_media"` | ||
GIFAutoPlay bool `json:"gif_auto_play"` | ||
RenderEmbeds bool `json:"render_embeds"` | ||
RenderReactions bool `json:"render_reactions"` | ||
AnimateEmoji bool `json:"animate_emoji"` | ||
EnableTTSCommand bool `json:"enable_tts_command"` | ||
MessageDisplayCompact bool `json:"message_display_compact"` | ||
ConvertEmoticons bool `json:"convert_emoticons"` | ||
ExplicitContentFilter uint8 `json:"explicit_content_filter"` // ??? | ||
DisableGamesTab bool `json:"disable_games_tab"` | ||
DeveloperMode bool `json:"developer_mode"` | ||
DetectPlatformAccounts bool `json:"detect_platform_accounts"` | ||
StreamNotification bool `json:"stream_notification_enabled"` | ||
AccessibilityDetection bool `json:"allow_accessbility_detection"` | ||
ContactSync bool `json:"contact_sync_enabled"` | ||
NativePhoneIntegration bool `json:"native_phone_integration_enabled"` | ||
|
||
Locale string `json:"locale"` | ||
Theme string `json:"theme"` | ||
|
||
GuildPositions []discord.Snowflake `json:"guild_positions"` | ||
GuildFolders []GuildFolder `json:"guild_folders"` | ||
RestrictedGuilds []discord.Snowflake `json:"restricted_guilds"` | ||
|
||
FriendSourceFlags struct { | ||
All bool `json:"all"` | ||
MutualGuilds bool `json:"mutual_guilds"` | ||
MutualFriends bool `json:"mutual_friends"` | ||
} `json:"friend_source_flags"` | ||
|
||
Status discord.Status `json:"status"` | ||
CustomStatus struct { | ||
Text string `json:"text"` | ||
ExpiresAt discord.Timestamp `json:"expires_at,omitempty"` | ||
EmojiID discord.Snowflake `json:"emoji_id,string"` | ||
EmojiName string `json:"emoji_name"` | ||
} `json:"custom_status"` | ||
} | ||
|
||
// A UserGuildSettingsChannelOverride stores data for a channel override for a | ||
// users guild settings. | ||
type SettingsChannelOverride struct { | ||
Muted bool `json:"muted"` | ||
MessageNotifications int `json:"message_notifications"` // TODO: document | ||
|
||
ChannelID discord.Snowflake `json:"channel_id"` | ||
} | ||
|
||
// A UserGuildSettings stores data for a users guild settings. | ||
type UserGuildSettings struct { | ||
SupressEveryone bool `json:"suppress_everyone"` | ||
Muted bool `json:"muted"` | ||
MobilePush bool `json:"mobile_push"` | ||
MessageNotifications int `json:"message_notifications"` | ||
|
||
GuildID discord.Snowflake `json:"guild_id"` | ||
ChannelOverrides []SettingsChannelOverride `json:"channel_overrides"` | ||
} | ||
|
||
// GuildFolder holds a single folder that you see in the left guild panel. | ||
type GuildFolder struct { | ||
Name string `json:"name"` | ||
ID int64 `json:"id"` | ||
GuildIDs []string `json:"guild_ids"` | ||
Color int64 `json:"color"` | ||
} | ||
|
||
// A Relationship between the logged in user and Relationship.User | ||
type Relationship struct { | ||
ID string `json:"id"` | ||
User discord.User `json:"user"` | ||
Type RelationshipType `json:"type"` | ||
} | ||
|
||
type RelationshipType uint8 | ||
|
||
const ( | ||
_ RelationshipType = iota | ||
FriendRelationship | ||
BlockedRelationship | ||
IncomingFriendRequest | ||
SentFriendRequest | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.