mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-25 02:23:04 +00:00
Fix potential conflicts in snowflake keys
This can happen on really old channels with the same ID as the guild ID and having a command with both a role and a channel.
This commit is contained in:
@@ -27,7 +27,7 @@ import inspect
|
||||
from typing import Callable, Dict, List, Literal, Optional, TYPE_CHECKING, Tuple, Type, Union, overload
|
||||
|
||||
|
||||
from .namespace import Namespace
|
||||
from .namespace import Namespace, ResolveKey
|
||||
from .models import AppCommand
|
||||
from .commands import Command, ContextMenu, Group, _shorten
|
||||
from .enums import AppCommandType
|
||||
@@ -532,8 +532,14 @@ class CommandTree:
|
||||
raise CommandNotFound(name, [], AppCommandType(type))
|
||||
|
||||
resolved = Namespace._get_resolved_items(interaction, data.get('resolved', {}))
|
||||
|
||||
target_id = data.get('target_id')
|
||||
# Right now, the only types are message and user
|
||||
# Therefore, there's no conflict with snowflakes
|
||||
|
||||
# This will always work at runtime
|
||||
value = resolved.get(data.get('target_id')) # type: ignore
|
||||
key = ResolveKey.any_with(target_id) # type: ignore
|
||||
value = resolved.get(key)
|
||||
if ctx_menu.type.value != type:
|
||||
raise CommandSignatureMismatch(ctx_menu)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user