mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-05-23 23:53:27 +00:00
Adopted several packages to use NullSnowflake and NullSeconds
This commit is contained in:
parent
4e1dd8e2f4
commit
23b0abdfec
10
api/guild.go
10
api/guild.go
|
@ -127,8 +127,8 @@ type ModifyGuildData struct {
|
||||||
Notification *discord.Notification `json:"default_message_notifications,omitempty"`
|
Notification *discord.Notification `json:"default_message_notifications,omitempty"`
|
||||||
ExplicitFilter *discord.ExplicitFilter `json:"explicit_content_filter,omitempty"`
|
ExplicitFilter *discord.ExplicitFilter `json:"explicit_content_filter,omitempty"`
|
||||||
|
|
||||||
AFKChannelID *discord.Snowflake `json:"afk_channel_id,string,omitempty"`
|
AFKChannelID discord.Snowflake `json:"afk_channel_id,string,omitempty"`
|
||||||
AFKTimeout *discord.Seconds `json:"afk_timeout,omitempty"`
|
AFKTimeout discord.Seconds `json:"afk_timeout,omitempty"`
|
||||||
|
|
||||||
OwnerID discord.Snowflake `json:"owner_id,omitempty"`
|
OwnerID discord.Snowflake `json:"owner_id,omitempty"`
|
||||||
|
|
||||||
|
@ -136,9 +136,9 @@ type ModifyGuildData struct {
|
||||||
Splash *Image `json:"splash,omitempty"`
|
Splash *Image `json:"splash,omitempty"`
|
||||||
Banner *Image `json:"banner,omitempty"`
|
Banner *Image `json:"banner,omitempty"`
|
||||||
|
|
||||||
SystemChannelID *discord.Snowflake `json:"system_channel_id,omitempty"`
|
SystemChannelID discord.Snowflake `json:"system_channel_id,omitempty"`
|
||||||
RulesChannelID *discord.Snowflake `json:"rules_channel_id,omitempty"`
|
RulesChannelID discord.Snowflake `json:"rules_channel_id,omitempty"`
|
||||||
PublicUpdatesChannelID *discord.Snowflake `json:"public_updates_channel_id,omitempty"`
|
PublicUpdatesChannelID discord.Snowflake `json:"public_updates_channel_id,omitempty"`
|
||||||
|
|
||||||
PreferredLocale json.OptionString `json:"preferred_locale,omitempty"`
|
PreferredLocale json.OptionString `json:"preferred_locale,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,18 +24,14 @@ func (c *Client) Invite(code string) (*discord.Invite, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelInvites is only for guild channels. GuildInvites is for guilds.
|
// ChannelInvites is only for guild channels. GuildInvites is for guilds.
|
||||||
func (c *Client) ChannelInvites(
|
func (c *Client) ChannelInvites(channelID discord.Snowflake) ([]discord.Invite, error) {
|
||||||
channelID discord.Snowflake) ([]discord.Invite, error) {
|
|
||||||
|
|
||||||
var invs []discord.Invite
|
var invs []discord.Invite
|
||||||
return invs, c.RequestJSON(&invs, "GET",
|
return invs, c.RequestJSON(&invs, "GET",
|
||||||
EndpointChannels+channelID.String()+"/invites")
|
EndpointChannels+channelID.String()+"/invites")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuildInvites is for guilds.
|
// GuildInvites is for guilds.
|
||||||
func (c *Client) GuildInvites(
|
func (c *Client) GuildInvites(guildID discord.Snowflake) ([]discord.Invite, error) {
|
||||||
guildID discord.Snowflake) ([]discord.Invite, error) {
|
|
||||||
|
|
||||||
var invs []discord.Invite
|
var invs []discord.Invite
|
||||||
return invs, c.RequestJSON(&invs, "GET",
|
return invs, c.RequestJSON(&invs, "GET",
|
||||||
EndpointGuilds+guildID.String()+"/invites")
|
EndpointGuilds+guildID.String()+"/invites")
|
||||||
|
|
|
@ -6,9 +6,7 @@ import (
|
||||||
"github.com/diamondburned/arikawa/utils/json"
|
"github.com/diamondburned/arikawa/utils/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) Member(
|
func (c *Client) Member(guildID, userID discord.Snowflake) (*discord.Member, error) {
|
||||||
guildID, userID discord.Snowflake) (*discord.Member, error) {
|
|
||||||
|
|
||||||
var m *discord.Member
|
var m *discord.Member
|
||||||
return m, c.RequestJSON(&m, "GET",
|
return m, c.RequestJSON(&m, "GET",
|
||||||
EndpointGuilds+guildID.String()+"/members/"+userID.String())
|
EndpointGuilds+guildID.String()+"/members/"+userID.String())
|
||||||
|
@ -89,7 +87,7 @@ type AnyMemberData struct {
|
||||||
Roles *[]discord.Snowflake `json:"roles,omitempty"`
|
Roles *[]discord.Snowflake `json:"roles,omitempty"`
|
||||||
|
|
||||||
// Only for ModifyMember, requires MOVE_MEMBER
|
// Only for ModifyMember, requires MOVE_MEMBER
|
||||||
VoiceChannel *discord.Snowflake `json:"channel_id,omitempty"`
|
VoiceChannel discord.Snowflake `json:"channel_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddMember requires access(Token).
|
// AddMember requires access(Token).
|
||||||
|
@ -98,7 +96,7 @@ func (c *Client) AddMember(
|
||||||
data AnyMemberData) (*discord.Member, error) {
|
data AnyMemberData) (*discord.Member, error) {
|
||||||
|
|
||||||
// VoiceChannel doesn't belong here.
|
// VoiceChannel doesn't belong here.
|
||||||
data.VoiceChannel = nil
|
data.VoiceChannel = -1
|
||||||
|
|
||||||
var param struct {
|
var param struct {
|
||||||
Token string `json:"access_token"`
|
Token string `json:"access_token"`
|
||||||
|
|
|
@ -32,9 +32,7 @@ type AnyRoleData struct {
|
||||||
Permissions discord.Permissions `json:"permissions,omitempty"` // @everyone
|
Permissions discord.Permissions `json:"permissions,omitempty"` // @everyone
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CreateRole(
|
func (c *Client) CreateRole(guildID discord.Snowflake, data AnyRoleData) (*discord.Role, error) {
|
||||||
guildID discord.Snowflake, data AnyRoleData) (*discord.Role, error) {
|
|
||||||
|
|
||||||
var role *discord.Role
|
var role *discord.Role
|
||||||
return role, c.RequestJSON(
|
return role, c.RequestJSON(
|
||||||
&role, "POST",
|
&role, "POST",
|
||||||
|
|
|
@ -68,10 +68,10 @@ func (g *Gateway) RequestGuildMembers(data RequestGuildMembersData) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateVoiceStateData struct {
|
type UpdateVoiceStateData struct {
|
||||||
GuildID discord.Snowflake `json:"guild_id"`
|
GuildID discord.Snowflake `json:"guild_id"`
|
||||||
ChannelID *discord.Snowflake `json:"channel_id"` // nullable
|
ChannelID discord.Snowflake `json:"channel_id"` // nullable
|
||||||
SelfMute bool `json:"self_mute"`
|
SelfMute bool `json:"self_mute"`
|
||||||
SelfDeaf bool `json:"self_deaf"`
|
SelfDeaf bool `json:"self_deaf"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Gateway) UpdateVoiceState(data UpdateVoiceStateData) error {
|
func (g *Gateway) UpdateVoiceState(data UpdateVoiceStateData) error {
|
||||||
|
|
|
@ -115,9 +115,9 @@ func (s *Session) JoinChannel(gID, cID discord.Snowflake, muted, deafened bool)
|
||||||
s.speaking = false
|
s.speaking = false
|
||||||
|
|
||||||
// Ensure that if `cID` is zero that it passes null to the update event.
|
// Ensure that if `cID` is zero that it passes null to the update event.
|
||||||
var channelID *discord.Snowflake
|
var channelID discord.Snowflake = -1
|
||||||
if cID.Valid() {
|
if cID.Valid() {
|
||||||
channelID = &cID
|
channelID = cID
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://discordapp.com/developers/docs/topics/voice-connections#retrieving-voice-server-information
|
// https://discordapp.com/developers/docs/topics/voice-connections#retrieving-voice-server-information
|
||||||
|
@ -225,7 +225,7 @@ func (s *Session) Disconnect() error {
|
||||||
|
|
||||||
err := s.session.Gateway.UpdateVoiceState(gateway.UpdateVoiceStateData{
|
err := s.session.Gateway.UpdateVoiceState(gateway.UpdateVoiceStateData{
|
||||||
GuildID: s.state.GuildID,
|
GuildID: s.state.GuildID,
|
||||||
ChannelID: nil,
|
ChannelID: discord.NullSnowflake,
|
||||||
SelfMute: true,
|
SelfMute: true,
|
||||||
SelfDeaf: true,
|
SelfDeaf: true,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue