mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-06 11:57:17 +00:00
Raise error if position could not be resolved in GuildChannel.move
This commit is contained in:
parent
7f0db1f35a
commit
0c3be9713d
@ -803,15 +803,18 @@ class GuildChannel:
|
|||||||
# If we're not there then it's probably due to not being in the category
|
# If we're not there then it's probably due to not being in the category
|
||||||
pass
|
pass
|
||||||
|
|
||||||
index = 0
|
index = None
|
||||||
if beginning:
|
if beginning:
|
||||||
index = 0
|
index = 0
|
||||||
elif end:
|
elif end:
|
||||||
index = len(channels)
|
index = len(channels)
|
||||||
elif before:
|
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:
|
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)
|
channels.insert(max((index + offset), 0), self)
|
||||||
payload = []
|
payload = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user