Raise error if position could not be resolved in GuildChannel.move

This commit is contained in:
Rapptz 2021-03-30 04:11:06 -04:00
parent 7f0db1f35a
commit 0c3be9713d

View File

@ -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 = []