aboutsummaryrefslogtreecommitdiff
path: root/discord/abc.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-03-30 04:11:06 -0400
committerRapptz <[email protected]>2021-03-30 04:11:06 -0400
commit0c3be9713d74c4b9fb90b0b9fee8f4680060c68e (patch)
treea346dcdec787f8812204ad2f99e6124322bce655 /discord/abc.py
parentReturn early if no kwargs are given to GuildChannel.move (diff)
downloaddiscord.py-0c3be9713d74c4b9fb90b0b9fee8f4680060c68e.tar.xz
discord.py-0c3be9713d74c4b9fb90b0b9fee8f4680060c68e.zip
Raise error if position could not be resolved in GuildChannel.move
Diffstat (limited to 'discord/abc.py')
-rw-r--r--discord/abc.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/discord/abc.py b/discord/abc.py
index ef7d403d..78dab420 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 = []