1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-02-10 13:33:14 +00:00

State: Error out on fetching permission of a channel not in guild

This commit is contained in:
diamondburned 2021-01-05 21:09:16 -08:00
parent 8a21375916
commit 771591e5eb

View file

@ -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 (