From 2c7b56ab6e00e013259902df20c5c2380d8d7712 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Tue, 5 Jan 2021 21:02:54 -0800 Subject: [PATCH] use the API even less --- internal/discord/channel/commands/commands.go | 2 +- internal/discord/folder/folder.go | 2 +- internal/discord/guild/guild.go | 12 ++++-------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/internal/discord/channel/commands/commands.go b/internal/discord/channel/commands/commands.go index 468e9b8..c82ccff 100644 --- a/internal/discord/channel/commands/commands.go +++ b/internal/discord/channel/commands/commands.go @@ -178,7 +178,7 @@ var World = Commands{ return nil, err } - m, err := ch.State.Member(ch.GuildID, user.ID()) + m, err := ch.State.Cabinet.Member(ch.GuildID, user.ID()) if err != nil { return nil, err } diff --git a/internal/discord/folder/folder.go b/internal/discord/folder/folder.go index 328fbcd..59cc064 100644 --- a/internal/discord/folder/folder.go +++ b/internal/discord/folder/folder.go @@ -67,7 +67,7 @@ func (gf *GuildFolder) Servers(container cchat.ServersContainer) error { var servers = make([]cchat.Server, 0, len(gf.GuildIDs)) for _, id := range gf.GuildIDs { - g, err := gf.state.Guild(id) + g, err := gf.state.Cabinet.Guild(id) if err != nil { continue } diff --git a/internal/discord/guild/guild.go b/internal/discord/guild/guild.go index 20c8070..e8733be 100644 --- a/internal/discord/guild/guild.go +++ b/internal/discord/guild/guild.go @@ -30,7 +30,7 @@ func New(s *state.Instance, g *discord.Guild) cchat.Server { } func NewFromID(s *state.Instance, gID discord.GuildID) (cchat.Server, error) { - g, err := s.Guild(gID) + g, err := s.Cabinet.Guild(gID) if err != nil { return nil, err } @@ -38,11 +38,7 @@ func NewFromID(s *state.Instance, gID discord.GuildID) (cchat.Server, error) { return New(s, g), nil } -func (g *Guild) self(ctx context.Context) (*discord.Guild, error) { - return g.state.WithContext(ctx).Guild(g.id) -} - -func (g *Guild) selfState() (*discord.Guild, error) { +func (g *Guild) self() (*discord.Guild, error) { return g.state.Cabinet.Guild(g.id) } @@ -51,7 +47,7 @@ func (g *Guild) ID() cchat.ID { } func (g *Guild) Name() text.Rich { - s, err := g.selfState() + s, err := g.self() if err != nil { // This shouldn't happen. return text.Rich{Content: g.id.String()} @@ -63,7 +59,7 @@ func (g *Guild) Name() text.Rich { func (g *Guild) AsIconer() cchat.Iconer { return g } func (g *Guild) Icon(ctx context.Context, iconer cchat.IconContainer) (func(), error) { - s, err := g.self(ctx) + s, err := g.self() if err != nil { // This shouldn't happen. return nil, errors.Wrap(err, "Failed to get guild")