Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix to add debug warning to catch deprecated perms v1 usage until v2 perms are implemented #1301

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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