Change some errors and fix interaction.channel fixing
This commit is contained in:
parent
f780de07d0
commit
cbf5118790
@ -99,11 +99,13 @@ class _FakeSlashMessage(discord.PartialMessage):
|
|||||||
tts = False
|
tts = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_interaction(cls, interaction: discord.Interaction) -> discord.Message:
|
def from_interaction(
|
||||||
self: discord.Message = cls(channel=interaction.channel, id=interaction.id) # type: ignore
|
cls, interaction: discord.Interaction, channel: Union[discord.TextChannel, discord.DMChannel, discord.Thread]
|
||||||
|
):
|
||||||
|
self = cls(channel=channel, id=interaction.id)
|
||||||
assert interaction.user is not None
|
assert interaction.user is not None
|
||||||
self.author = interaction.user
|
self.author = interaction.user
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
@ -233,7 +235,7 @@ class BotBase(GroupMixin):
|
|||||||
raise TypeError(f"owner_ids must be a collection not {self.owner_ids.__class__!r}")
|
raise TypeError(f"owner_ids must be a collection not {self.owner_ids.__class__!r}")
|
||||||
|
|
||||||
if not (message_commands or slash_commands):
|
if not (message_commands or slash_commands):
|
||||||
raise TypeError("Both message_commands and slash_commands are disabled.")
|
raise ValueError("Both message_commands and slash_commands are disabled.")
|
||||||
|
|
||||||
if help_command is _default:
|
if help_command is _default:
|
||||||
self.help_command = DefaultHelpCommand()
|
self.help_command = DefaultHelpCommand()
|
||||||
@ -1259,11 +1261,8 @@ class BotBase(GroupMixin):
|
|||||||
else:
|
else:
|
||||||
return # cannot do anything without stable channel
|
return # cannot do anything without stable channel
|
||||||
|
|
||||||
interaction.channel = channel # type: ignore
|
|
||||||
del channel
|
|
||||||
|
|
||||||
# Fetch a valid prefix, so process_commands can function
|
# Fetch a valid prefix, so process_commands can function
|
||||||
message = _FakeSlashMessage.from_interaction(interaction)
|
message: discord.Message = _FakeSlashMessage.from_interaction(interaction, channel) # type: ignore
|
||||||
prefix = await self.get_prefix(message)
|
prefix = await self.get_prefix(message)
|
||||||
if isinstance(prefix, list):
|
if isinstance(prefix, list):
|
||||||
prefix = prefix[0]
|
prefix = prefix[0]
|
||||||
|
@ -429,7 +429,9 @@ class Command(_BaseCommand, Generic[CogT, P, T]):
|
|||||||
parent = kwargs.get("parent")
|
parent = kwargs.get("parent")
|
||||||
self.parent: Optional[GroupMixin] = parent if isinstance(parent, _BaseCommand) else None # type: ignore
|
self.parent: Optional[GroupMixin] = parent if isinstance(parent, _BaseCommand) else None # type: ignore
|
||||||
if self.slash_command_guilds is not None and self.parent is not None:
|
if self.slash_command_guilds is not None and self.parent is not None:
|
||||||
raise TypeError("Cannot set specific guilds for a subcommand. They are inherited from the top level group.")
|
raise ValueError(
|
||||||
|
"Cannot set specific guilds for a subcommand. They are inherited from the top level group."
|
||||||
|
)
|
||||||
|
|
||||||
self._before_invoke: Optional[Hook] = None
|
self._before_invoke: Optional[Hook] = None
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user