Skip to content

Commit

Permalink
Slash Command Channel Parsing Bug Fixes (#1257)
Browse files Browse the repository at this point in the history
* Update core.py

* Update channel.py

* Update channel.py

* Update channel.py

Co-authored-by: BobDotCom <71356958+BobDotCom@users.noreply.github.com>
  • Loading branch information
plun1331 and BobDotCom authored Apr 14, 2022
1 parent d3d21f4 commit 9fdfd56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
The category channel ID this channel belongs to, if applicable.
topic: Optional[:class:`str`]
The channel's topic. ``None`` if it doesn't exist.
position: :class:`int`
position: Optional[:class:`int`]
The position in the channel list. This is a number that starts at 0. e.g. the
top channel is position 0.
top channel is position 0. Can be ``None`` if the channel was recieved in an interaction.
last_message_id: Optional[:class:`int`]
The last message ID of the message sent to this channel. It may
*not* point to an existing or valid message.
Expand Down Expand Up @@ -192,7 +192,7 @@ def _update(self, guild: Guild, data: TextChannelPayload) -> None:
self.name: str = data["name"]
self.category_id: Optional[int] = utils._get_as_snowflake(data, "parent_id")
self.topic: Optional[str] = data.get("topic")
self.position: int = data["position"]
self.position: int = data.get("position")
self.nsfw: bool = data.get("nsfw", False)
# Does this need coercion into `int`? No idea yet.
self.slowmode_delay: int = data.get("rate_limit_per_user", 0)
Expand Down Expand Up @@ -816,7 +816,7 @@ def _update(self, guild: Guild, data: Union[VoiceChannelPayload, StageChannelPay
self.video_quality_mode: VideoQualityMode = try_enum(VideoQualityMode, data.get("video_quality_mode", 1))
self.category_id: Optional[int] = utils._get_as_snowflake(data, "parent_id")
self.last_message_id: Optional[int] = utils._get_as_snowflake(data, 'last_message_id')
self.position: int = data["position"]
self.position: int = data.get("position")
self.bitrate: int = data.get("bitrate")
self.user_limit: int = data.get("user_limit")
self._fill_overwrites(data)
Expand Down Expand Up @@ -902,9 +902,9 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
The channel ID.
category_id: Optional[:class:`int`]
The category channel ID this channel belongs to, if applicable.
position: :class:`int`
position: Optional[:class:`int`]
The position in the channel list. This is a number that starts at 0. e.g. the
top channel is position 0.
top channel is position 0. Can be ``None`` if the channel was recieved in an interaction.
bitrate: :class:`int`
The channel's preferred audio bitrate in bits per second.
user_limit: :class:`int`
Expand Down Expand Up @@ -1374,9 +1374,9 @@ class StageChannel(VocalGuildChannel):
The channel's topic. ``None`` if it isn't set.
category_id: Optional[:class:`int`]
The category channel ID this channel belongs to, if applicable.
position: :class:`int`
position: Optional[:class:`int`]
The position in the channel list. This is a number that starts at 0. e.g. the
top channel is position 0.
top channel is position 0. Can be ``None`` if the channel was recieved in an interaction.
bitrate: :class:`int`
The channel's preferred audio bitrate in bits per second.
user_limit: :class:`int`
Expand Down Expand Up @@ -1651,9 +1651,9 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
The guild the category belongs to.
id: :class:`int`
The category channel ID.
position: :class:`int`
position: Optional[:class:`int`]
The position in the category list. This is a number that starts at 0. e.g. the
top category is position 0.
top category is position 0. Can be ``None`` if the channel was recieved in an interaction.
nsfw: :class:`bool`
If the channel is marked as "not safe for work".
Expand Down Expand Up @@ -1686,7 +1686,7 @@ def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
self.name: str = data["name"]
self.category_id: Optional[int] = utils._get_as_snowflake(data, "parent_id")
self.nsfw: bool = data.get("nsfw", False)
self.position: int = data["position"]
self.position: int = data.get("position")
self._fill_overwrites(data)

@property
Expand Down
2 changes: 1 addition & 1 deletion discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ async def _invoke(self, ctx: ApplicationContext) -> None:
obj_type = Role
kw["guild"] = ctx.guild
elif op.input_type is SlashCommandOptionType.channel:
obj_type = _guild_channel_factory(_data["type"])
obj_type = _guild_channel_factory(_data["type"])[0]
kw["guild"] = ctx.guild
elif op.input_type is SlashCommandOptionType.attachment:
obj_type = Attachment
Expand Down

0 comments on commit 9fdfd56

Please sign in to comment.