Skip to content

Commit

Permalink
move roles, emojis. stickers to different struct so those slices are …
Browse files Browse the repository at this point in the history
…not cached
  • Loading branch information
topi314 committed Mar 27, 2022
1 parent 4390ee2 commit f888f90
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions discord/guild.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ type Guild struct {
VerificationLevel VerificationLevel `json:"verification_level"`
DefaultMessageNotifications MessageNotificationsLevel `json:"default_message_notifications"`
ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"`
Roles []Role `json:"roles"`
Emojis []Emoji `json:"emojis"`
Features []GuildFeature `json:"features"`
MFALevel MFALevel `json:"mfa_level"`
ApplicationID *snowflake.Snowflake `json:"application_id"`
Expand All @@ -132,7 +130,6 @@ type Guild struct {
WelcomeScreen WelcomeScreen `json:"welcome_screen"`
NSFWLevel NSFWLevel `json:"nsfw_level"`
BoostProgressBarEnabled bool `json:"premium_progress_bar_enabled"`
Stickers []Sticker `json:"stickers"`
JoinedAt Time `json:"joined_at"`

// only over GET /guilds/{guild.id}
Expand Down Expand Up @@ -168,8 +165,15 @@ func (g Guild) BannerURL(opts ...CDNOpt) *string {
return formatAssetURL(route.GuildBanner, opts, g.ID, *g.Banner)
}

type GatewayGuild struct {
type RestGuild struct {
Guild
Stickers []Sticker `json:"stickers"`
Roles []Role `json:"roles"`
Emojis []Emoji `json:"emojis"`
}

type GatewayGuild struct {
RestGuild
Large bool `json:"large"`
Unavailable bool `json:"unavailable"`
VoiceStates []VoiceState `json:"voice_states"`
Expand Down
12 changes: 6 additions & 6 deletions rest/guilds.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func NewGuilds(restClient Client) Guilds {
}

type Guilds interface {
GetGuild(guildID snowflake.Snowflake, withCounts bool, opts ...RequestOpt) (*discord.Guild, error)
GetGuild(guildID snowflake.Snowflake, withCounts bool, opts ...RequestOpt) (*discord.RestGuild, error)
GetGuildPreview(guildID snowflake.Snowflake, opts ...RequestOpt) (*discord.GuildPreview, error)
CreateGuild(guildCreate discord.GuildCreate, opts ...RequestOpt) (*discord.Guild, error)
UpdateGuild(guildID snowflake.Snowflake, guildUpdate discord.GuildUpdate, opts ...RequestOpt) (*discord.Guild, error)
CreateGuild(guildCreate discord.GuildCreate, opts ...RequestOpt) (*discord.RestGuild, error)
UpdateGuild(guildID snowflake.Snowflake, guildUpdate discord.GuildUpdate, opts ...RequestOpt) (*discord.RestGuild, error)
DeleteGuild(guildID snowflake.Snowflake, opts ...RequestOpt) error

CreateGuildChannel(guildID snowflake.Snowflake, guildChannelCreate discord.GuildChannelCreate, opts ...RequestOpt) (discord.GuildChannel, error)
Expand Down Expand Up @@ -47,7 +47,7 @@ type guildImpl struct {
restClient Client
}

func (s *guildImpl) GetGuild(guildID snowflake.Snowflake, withCounts bool, opts ...RequestOpt) (guild *discord.Guild, err error) {
func (s *guildImpl) GetGuild(guildID snowflake.Snowflake, withCounts bool, opts ...RequestOpt) (guild *discord.RestGuild, err error) {
values := route.QueryValues{}
if withCounts {
values["withCounts"] = true
Expand All @@ -71,7 +71,7 @@ func (s *guildImpl) GetGuildPreview(guildID snowflake.Snowflake, opts ...Request
return
}

func (s *guildImpl) CreateGuild(guildCreate discord.GuildCreate, opts ...RequestOpt) (guild *discord.Guild, err error) {
func (s *guildImpl) CreateGuild(guildCreate discord.GuildCreate, opts ...RequestOpt) (guild *discord.RestGuild, err error) {
var compiledRoute *route.CompiledAPIRoute
compiledRoute, err = route.CreateGuild.Compile(nil)
if err != nil {
Expand All @@ -81,7 +81,7 @@ func (s *guildImpl) CreateGuild(guildCreate discord.GuildCreate, opts ...Request
return
}

func (s *guildImpl) UpdateGuild(guildID snowflake.Snowflake, guildUpdate discord.GuildUpdate, opts ...RequestOpt) (guild *discord.Guild, err error) {
func (s *guildImpl) UpdateGuild(guildID snowflake.Snowflake, guildUpdate discord.GuildUpdate, opts ...RequestOpt) (guild *discord.RestGuild, err error) {
var compiledRoute *route.CompiledAPIRoute
compiledRoute, err = route.UpdateGuild.Compile(nil, guildID)
if err != nil {
Expand Down

0 comments on commit f888f90

Please sign in to comment.