mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-30 23:30:02 +00:00
[commands] Mock interaction context prefix
Most user-level code probably expects the prefix to be valid and not None, so mocking it to ensure it's at least a string is probably for the best.
This commit is contained in:
parent
89b9f1616c
commit
4fb1309e2a
@ -116,7 +116,8 @@ class Context(discord.abc.Messageable, Generic[BotT]):
|
|||||||
|
|
||||||
.. versionadded:: 2.0
|
.. versionadded:: 2.0
|
||||||
prefix: Optional[:class:`str`]
|
prefix: Optional[:class:`str`]
|
||||||
The prefix that was used to invoke the command.
|
The prefix that was used to invoke the command. For interaction based contexts,
|
||||||
|
this is ``/`` for slash commands and ``\u200b`` for context menu commands.
|
||||||
command: Optional[:class:`Command`]
|
command: Optional[:class:`Command`]
|
||||||
The command that is being invoked currently.
|
The command that is being invoked currently.
|
||||||
invoked_with: Optional[:class:`str`]
|
invoked_with: Optional[:class:`str`]
|
||||||
@ -250,12 +251,14 @@ class Context(discord.abc.Messageable, Generic[BotT]):
|
|||||||
else:
|
else:
|
||||||
message = interaction.message
|
message = interaction.message
|
||||||
|
|
||||||
|
prefix = '/' if data.get('type', 1) == 1 else '\u200b' # Mock the prefix
|
||||||
return cls(
|
return cls(
|
||||||
message=message,
|
message=message,
|
||||||
bot=bot,
|
bot=bot,
|
||||||
view=StringView(''),
|
view=StringView(''),
|
||||||
args=[],
|
args=[],
|
||||||
kwargs={},
|
kwargs={},
|
||||||
|
prefix=prefix,
|
||||||
interaction=interaction,
|
interaction=interaction,
|
||||||
invoked_with=command.name,
|
invoked_with=command.name,
|
||||||
command=command, # type: ignore # this will be a hybrid command, technically
|
command=command, # type: ignore # this will be a hybrid command, technically
|
||||||
|
Loading…
x
Reference in New Issue
Block a user