From 771591e5eb651519f7c51cd2c40a0d7f2d0a99cf Mon Sep 17 00:00:00 2001 From: diamondburned Date: Tue, 5 Jan 2021 21:09:16 -0800 Subject: [PATCH] State: Error out on fetching permission of a channel not in guild --- state/state.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/state/state.go b/state/state.go index 3c44d5c..cbdb74f 100644 --- a/state/state.go +++ b/state/state.go @@ -262,6 +262,8 @@ func (s *State) MemberColor(guildID discord.GuildID, userID discord.UserID) (dis //// +// Permissions gets the user's permissions in the given channel. If the channel +// is not in any guild, then an error is returned. func (s *State) Permissions( channelID discord.ChannelID, userID discord.UserID) (discord.Permissions, error) { @@ -270,6 +272,10 @@ func (s *State) Permissions( return 0, errors.Wrap(err, "failed to get channel") } + if !ch.GuildID.IsValid() { + return 0, errors.New("channel is not in a guild") + } + var wg sync.WaitGroup var (