From 0c3be9713d74c4b9fb90b0b9fee8f4680060c68e Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 30 Mar 2021 04:11:06 -0400 Subject: [PATCH] Raise error if position could not be resolved in GuildChannel.move --- discord/abc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/discord/abc.py b/discord/abc.py index ef7d403d5..78dab4205 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -803,15 +803,18 @@ class GuildChannel: # If we're not there then it's probably due to not being in the category pass - index = 0 + index = None if beginning: index = 0 elif end: index = len(channels) elif before: - index = next((i for i, c in enumerate(channels) if c.id == before.id), 0) + index = next((i for i, c in enumerate(channels) if c.id == before.id), None) elif after: - index = next((i + 1 for i, c in enumerate(channels) if c.id == after.id), len(channels)) + index = next((i + 1 for i, c in enumerate(channels) if c.id == after.id), None) + + if index is None: + raise InvalidArgument('Could not resolve appropriate move position') channels.insert(max((index + offset), 0), self) payload = []