Skip to content

Commit

Permalink
add debug warning to catch deprecated perms v1 usage until v2 perms a…
Browse files Browse the repository at this point in the history
…re implemented in #1183 (#1301)
  • Loading branch information
krittick authored Apr 27, 2022
1 parent 7e574cb commit 22d9c92
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
command,
)
from .enums import InteractionType
from .errors import CheckFailure, DiscordException, Forbidden
from .errors import CheckFailure, DiscordException, Forbidden, HTTPException
from .interactions import Interaction
from .shard import AutoShardedClient
from .types import interactions
Expand Down Expand Up @@ -647,7 +647,7 @@ async def sync_commands(

# TODO: 2.1: Remove this and favor permissions v2
# Global Command Permissions

if not _register_permissions:
return

Expand Down Expand Up @@ -778,6 +778,10 @@ async def sync_commands(
f"Failed to add command permissions to guild {guild_id}",
file=sys.stderr,
)
except HTTPException:
_log.warning(
"Command Permissions V2 not yet implemented, permissions will not be set for your commands."
)

async def process_application_commands(self, interaction: Interaction, auto_sync: bool = None) -> None:
"""|coro|
Expand Down Expand Up @@ -818,11 +822,10 @@ async def process_application_commands(self, interaction: Interaction, auto_sync
except KeyError:
for cmd in self.application_commands:
guild_id = interaction.data.get("guild_id")
if guild_id:
if guild_id:
guild_id = int(guild_id)
if cmd.name == interaction.data["name"] and (
guild_id == cmd.guild_ids
or (isinstance(cmd.guild_ids, list) and guild_id in cmd.guild_ids)
guild_id == cmd.guild_ids or (isinstance(cmd.guild_ids, list) and guild_id in cmd.guild_ids)
):
command = cmd
break
Expand Down

0 comments on commit 22d9c92

Please sign in to comment.