forked from pothtonswer/discordmuffin
Stop trying to fight Discord's Int's as Strings and just use strings.
This commit is contained in:
parent
f87340f1e8
commit
05ff822438
5 changed files with 61 additions and 83 deletions
|
@ -1,22 +1,22 @@
|
|||
package discordgo
|
||||
|
||||
type Channel struct {
|
||||
GuildId int `json:"guild_id,string,omitempty"`
|
||||
Id int `json:"id,string"`
|
||||
Id string `json:"id"`
|
||||
GuildId string `json:"guild_idomitempty"`
|
||||
Name string `json:"name"`
|
||||
Topic string `json:"topic"`
|
||||
Position int `json:"position"`
|
||||
Type string `json:"type"`
|
||||
PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"`
|
||||
IsPrivate bool `json:"is_private"`
|
||||
LastMessageId int `json:"last_message_id,string"`
|
||||
LastMessageId string `json:"last_message_id"`
|
||||
Recipient User `json:"recipient"`
|
||||
Session *Session
|
||||
}
|
||||
|
||||
type PermissionOverwrite struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Id int `json:"id,string"`
|
||||
Deny int `json:"deny"`
|
||||
Allow int `json:"allow"`
|
||||
}
|
||||
|
|
16
guild.go
16
guild.go
|
@ -1,15 +1,15 @@
|
|||
package discordgo
|
||||
|
||||
type Guild struct {
|
||||
Id int `json:"id,string"`
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Region string `json:"region"`
|
||||
AfkTimeout int `json:"afk_timeout"`
|
||||
AfkChannelId int `json:"afk_channel_id,string"`
|
||||
EmbedChannelId int `json:"embed_channel_id,string"`
|
||||
AfkChannelId string `json:"afk_channel_id"`
|
||||
EmbedChannelId string `json:"embed_channel_id"`
|
||||
EmbedEnabled bool `json:"embed_enabled"`
|
||||
OwnerId int `json:"owner_id,string"`
|
||||
OwnerId string `json:"owner_id"`
|
||||
Large bool `json:"large"` // ??
|
||||
JoinedAt string `json:"joined_at"` // make this a timestamp
|
||||
Roles []Role `json:"roles"`
|
||||
|
@ -20,7 +20,7 @@ type Guild struct {
|
|||
}
|
||||
|
||||
type Role struct {
|
||||
Id int `json:"id,string"`
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Managed bool `json:"managed"`
|
||||
Color int `json:"color"`
|
||||
|
@ -30,14 +30,14 @@ type Role struct {
|
|||
}
|
||||
|
||||
type VoiceState struct {
|
||||
UserId int `json:"user_id,string"`
|
||||
UserId string `json:"user_id"`
|
||||
Suppress bool `json:"suppress"`
|
||||
SessionId string `json:"session_id"`
|
||||
SelfMute bool `json:"self_mute"`
|
||||
SelfDeaf bool `json:"self_deaf"`
|
||||
Mute bool `json:"mute"`
|
||||
Deaf bool `json:"deaf"`
|
||||
ChannelId int `json:"channel_id,string"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
}
|
||||
|
||||
type Presence struct {
|
||||
|
@ -48,7 +48,7 @@ type Presence struct {
|
|||
|
||||
// TODO: Member vs User?
|
||||
type Member struct {
|
||||
GuildId int `json:"guild_id,string"`
|
||||
GuildId string `json:"guild_id"`
|
||||
JoinedAt string `json:"joined_at"`
|
||||
Deaf bool `json:"deaf"`
|
||||
mute bool `json:"mute"`
|
||||
|
|
49
restapi.go
49
restapi.go
|
@ -15,7 +15,6 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
sv "strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -39,8 +38,8 @@ const (
|
|||
REGISTER = AUTH + "register"
|
||||
|
||||
VOICE = API + "/voice/"
|
||||
REGIONS = API + VOICE + "regions"
|
||||
ICE = API + VOICE + "ice"
|
||||
REGIONS = VOICE + "regions"
|
||||
ICE = VOICE + "ice"
|
||||
|
||||
TUTORIAL = API + "tutorial/"
|
||||
TUTORIAL_INDICATORS = TUTORIAL + "indicators"
|
||||
|
@ -62,24 +61,24 @@ var (
|
|||
USER_DEVICES = func(userId string) string { return USERS + userId + "/devices" }
|
||||
USER_CONNECTIONS = func(userId string) string { return USERS + userId + "/connections" }
|
||||
|
||||
GUILD = func(guildId int) string { return GUILDS + sv.Itoa(guildId) }
|
||||
GUILD_CHANNELS = func(guildId int) string { return GUILDS + sv.Itoa(guildId) + "/channels" }
|
||||
GUILD_MEMBERS = func(guildId int) string { return GUILDS + sv.Itoa(guildId) + "/members" }
|
||||
GUILD_INTEGRATIONS = func(guildId int) string { return GUILDS + sv.Itoa(guildId) + "/integrations" }
|
||||
GUILD_BANS = func(guildId int) string { return GUILDS + sv.Itoa(guildId) + "/bans" }
|
||||
GUILD_ROLES = func(guildId int) string { return GUILDS + sv.Itoa(guildId) + "/roles" }
|
||||
GUILD_INVITES = func(guildId int) string { return GUILDS + sv.Itoa(guildId) + "/invites" }
|
||||
GUILD_EMBED = func(guildId int) string { return GUILDS + sv.Itoa(guildId) + "/embed" }
|
||||
GUILD_PRUNE = func(guildId int) string { return GUILDS + sv.Itoa(guildId) + "/prune" }
|
||||
GUILD_ICON = func(guildId int, hash string) string { return GUILDS + sv.Itoa(guildId) + "/icons/" + hash + ".jpg" }
|
||||
GUILD = func(guildId string) string { return GUILDS + guildId }
|
||||
GUILD_CHANNELS = func(guildId string) string { return GUILDS + guildId + "/channels" }
|
||||
GUILD_MEMBERS = func(guildId string) string { return GUILDS + guildId + "/members" }
|
||||
GUILD_INTEGRATIONS = func(guildId string) string { return GUILDS + guildId + "/integrations" }
|
||||
GUILD_BANS = func(guildId string) string { return GUILDS + guildId + "/bans" }
|
||||
GUILD_ROLES = func(guildId string) string { return GUILDS + guildId + "/roles" }
|
||||
GUILD_INVITES = func(guildId string) string { return GUILDS + guildId + "/invites" }
|
||||
GUILD_EMBED = func(guildId string) string { return GUILDS + guildId + "/embed" }
|
||||
GUILD_PRUNE = func(guildId string) string { return GUILDS + guildId + "/prune" }
|
||||
GUILD_ICON = func(guildId, hash string) string { return GUILDS + guildId + "/icons/" + hash + ".jpg" }
|
||||
|
||||
CHANNEL = func(channelId int) string { return CHANNELS + sv.Itoa(channelId) }
|
||||
CHANNEL_MESSAGES = func(channelId int) string { return CHANNELS + sv.Itoa(channelId) + "/messages" }
|
||||
CHANNEL_PERMISSIONS = func(channelId int) string { return CHANNELS + sv.Itoa(channelId) + "/permissions" }
|
||||
CHANNEL_INVITES = func(channelId int) string { return CHANNELS + sv.Itoa(channelId) + "/invites" }
|
||||
CHANNEL_TYPING = func(channelId int) string { return CHANNELS + sv.Itoa(channelId) + "/typing" }
|
||||
CHANNEL = func(channelId string) string { return CHANNELS + channelId }
|
||||
CHANNEL_MESSAGES = func(channelId string) string { return CHANNELS + channelId + "/messages" }
|
||||
CHANNEL_PERMISSIONS = func(channelId string) string { return CHANNELS + channelId + "/permissions" }
|
||||
CHANNEL_INVITES = func(channelId string) string { return CHANNELS + channelId + "/invites" }
|
||||
CHANNEL_TYPING = func(channelId string) string { return CHANNELS + channelId + "/typing" }
|
||||
|
||||
INTEGRATIONS_JOIN = func(intId int) string { return API + "integrations/" + sv.Itoa(intId) + "/join" }
|
||||
INTEGRATIONS_JOIN = func(intId string) string { return API + "integrations/" + intId + "/join" }
|
||||
)
|
||||
|
||||
// Request makes a (GET/POST/?) Requests to Discord REST API.
|
||||
|
@ -225,7 +224,7 @@ func (s *Session) UserGuilds(userId string) (st []Guild, err error) {
|
|||
|
||||
// Guild returns a Guild structure of a specific Guild.
|
||||
// guildId : The ID of the Guild you want returend.
|
||||
func (s *Session) Guild(guildId int) (st []Guild, err error) {
|
||||
func (s *Session) Guild(guildId string) (st []Guild, err error) {
|
||||
|
||||
body, err := s.Request("GET", GUILD(guildId), ``)
|
||||
err = json.Unmarshal(body, &st)
|
||||
|
@ -235,7 +234,7 @@ func (s *Session) Guild(guildId int) (st []Guild, err error) {
|
|||
// GuildMembers returns an array of Member structures for all members of a
|
||||
// given guild.
|
||||
// guildId : The ID of a Guild.
|
||||
func (s *Session) GuildMembers(guildId int) (st []Member, err error) {
|
||||
func (s *Session) GuildMembers(guildId string) (st []Member, err error) {
|
||||
|
||||
body, err := s.Request("GET", GUILD_MEMBERS(guildId), ``)
|
||||
err = json.Unmarshal(body, &st)
|
||||
|
@ -245,7 +244,7 @@ func (s *Session) GuildMembers(guildId int) (st []Member, err error) {
|
|||
// GuildChannels returns an array of Channel structures for all channels of a
|
||||
// given guild.
|
||||
// guildId : The ID of a Guild.
|
||||
func (s *Session) GuildChannels(guildId int) (st []Channel, err error) {
|
||||
func (s *Session) GuildChannels(guildId string) (st []Channel, err error) {
|
||||
|
||||
body, err := s.Request("GET", GUILD_CHANNELS(guildId), ``)
|
||||
err = json.Unmarshal(body, &st)
|
||||
|
@ -259,7 +258,7 @@ func (s *Session) GuildChannels(guildId int) (st []Channel, err error) {
|
|||
|
||||
// Channel returns a Channel strucutre of a specific Channel.
|
||||
// channelId : The ID of the Channel you want returend.
|
||||
func (s *Session) Channel(channelId int) (st Channel, err error) {
|
||||
func (s *Session) Channel(channelId string) (st Channel, err error) {
|
||||
body, err := s.Request("GET", CHANNEL(channelId), ``)
|
||||
err = json.Unmarshal(body, &st)
|
||||
return
|
||||
|
@ -271,7 +270,7 @@ func (s *Session) Channel(channelId int) (st Channel, err error) {
|
|||
// limit : The number messages that can be returned.
|
||||
// beforeId : If provided all messages returned will be before given ID.
|
||||
// afterId : If provided all messages returned will be after given ID.
|
||||
func (s *Session) ChannelMessages(channelId int, limit int, beforeId int, afterId int) (st []Message, err error) {
|
||||
func (s *Session) ChannelMessages(channelId string, limit int, beforeId int, afterId int) (st []Message, err error) {
|
||||
|
||||
var urlStr string = ""
|
||||
|
||||
|
@ -303,7 +302,7 @@ func (s *Session) ChannelMessages(channelId int, limit int, beforeId int, afterI
|
|||
// ChannelMessageSend sends a message to the given channel.
|
||||
// channelId : The ID of a Channel.
|
||||
// content : The message to send.
|
||||
func (s *Session) ChannelMessageSend(channelId int, content string) (st Message, err error) {
|
||||
func (s *Session) ChannelMessageSend(channelId string, content string) (st Message, err error) {
|
||||
|
||||
response, err := s.Request("POST", CHANNEL_MESSAGES(channelId), fmt.Sprintf(`{"content":"%s"}`, content))
|
||||
err = json.Unmarshal(response, &st)
|
||||
|
|
17
users.go
17
users.go
|
@ -1,7 +1,7 @@
|
|||
package discordgo
|
||||
|
||||
type User struct {
|
||||
Id int `json:"id,string"`
|
||||
Id string `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
Avatar string `json:"Avatar"`
|
||||
|
@ -19,9 +19,9 @@ type User struct {
|
|||
// field correctly. Need to research this more.
|
||||
|
||||
type PrivateChannel struct {
|
||||
Id int `json:"id,string"`
|
||||
Id string `json:"id"`
|
||||
IsPrivate bool `json:"is_private"`
|
||||
LastMessageId int `json:"last_message_id,string"`
|
||||
LastMessageId string `json:"last_message_id"`
|
||||
Recipient User `json:"recipient"`
|
||||
} // merge with channel?
|
||||
|
||||
|
@ -33,16 +33,7 @@ type Settings struct {
|
|||
Locale string `json:"locale"`
|
||||
ShowCurrentGame bool `json:"show_current_game"`
|
||||
Theme string `json:"theme"`
|
||||
//MutedChannels []string `json:"muted_channels"` // TODO, see below
|
||||
MutedChannels []int `json:"muted_channels,string"` // TODO, see below
|
||||
// MutedChannels []MutedChannel `json:"muted_channels"`
|
||||
MutedChannels []string `json:"muted_channels"`
|
||||
}
|
||||
|
||||
type MutedChannel struct {
|
||||
mc int `json:",string"`
|
||||
}
|
||||
|
||||
// MutedChannels should be an array of ints...
|
||||
// need to find a way to make that happen
|
||||
|
||||
// PM function to PM a user.
|
||||
|
|
34
wsapi.go
34
wsapi.go
|
@ -44,48 +44,36 @@ type Ready struct {
|
|||
// of all my channels when first connecting. I think :)
|
||||
type ReadState struct {
|
||||
MentionCount int
|
||||
LastMessageID int `json:"last_message_id,string"`
|
||||
ID int `json:"id,string"`
|
||||
LastMessageId string `json:"last_message_id"`
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type TypingStart struct {
|
||||
UserId int `json:"user_id,string"`
|
||||
ChannelId int `json:"channel_id,string"`
|
||||
UserId string `json:"user_id"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
Timestamp int `json:"timestamp"`
|
||||
}
|
||||
|
||||
type PresenceUpdate struct {
|
||||
User User `json:"user"`
|
||||
Status string `json:"status"`
|
||||
Roles []string `json:"roles"` // TODO: Should be ints, see below
|
||||
GuildId int `json:"guild_id,string"`
|
||||
Roles []string `json:"roles"`
|
||||
GuildId string `json:"guild_id"`
|
||||
GameId int `json:"game_id"`
|
||||
}
|
||||
|
||||
//Roles []string `json:"roles"` // TODO: Should be ints, see below
|
||||
// Above "Roles" should be an array of ints
|
||||
// TODO: Figure out how to make it be one.
|
||||
/*
|
||||
{
|
||||
"roles": [
|
||||
"89544728336416768",
|
||||
"110429733396676608"
|
||||
],
|
||||
}
|
||||
*/
|
||||
|
||||
type MessageAck struct {
|
||||
MessageId int `json:"message_id,string"`
|
||||
ChannelId int `json:"channel_id,string"`
|
||||
MessageId string `json:"message_id"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
}
|
||||
|
||||
type MessageDelete struct {
|
||||
Id int `json:"id,string"`
|
||||
ChannelId int `json:"channel_id,string"`
|
||||
Id string `json:"id"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
} // so much like MessageAck..
|
||||
|
||||
type GuildIntegrationsUpdate struct {
|
||||
GuildId int `json:"guild_id,string"`
|
||||
GuildId string `json:"guild_id"`
|
||||
}
|
||||
|
||||
type GuildRoleUpdate struct {
|
||||
|
|
Loading…
Reference in a new issue