Skip to content

Commit 5b92e40

Browse files
committed
Added warning when use both hidden and embeds
1 parent 21bf2b3 commit 5b92e40

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

discord_slash/model.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from discord.ext import commands
44
from . import http
55
from . import error
6+
from .client import SlashCommand
67

78

89
class SlashContext:
@@ -18,6 +19,7 @@ class SlashContext:
1819
:ivar command_id: ID of the command.
1920
:ivar _http: :class:`.http.SlashCommandRequest` of the client.
2021
:ivar _discord: :class:`discord.ext.commands.Bot`
22+
:ivar slashcommand: :class:`.client.SlashCommand`
2123
:ivar sent: Whether you sent the initial response.
2224
:ivar guild: :class:`discord.Guild` instance of the command message.
2325
:ivar author: :class:`discord.Member` instance representing author of the command message.
@@ -27,13 +29,15 @@ class SlashContext:
2729
def __init__(self,
2830
_http: http.SlashCommandRequest,
2931
_json: dict,
30-
_discord: typing.Union[discord.Client, commands.Bot]):
32+
_discord: typing.Union[discord.Client, commands.Bot],
33+
slashcommand: SlashCommand):
3134
self.__token = _json["token"]
3235
self.name = _json["data"]["name"]
3336
self.interaction_id = _json["id"]
3437
self.command_id = _json["data"]["id"]
3538
self._http = _http
3639
self._discord = _discord
40+
self.slashcommand = slashcommand
3741
self.sent = False
3842
self.guild: discord.Guild = _discord.get_guild(int(_json["guild_id"]))
3943
self.author: discord.Member = self.guild.get_member(int(_json["member"]["user"]["id"])) if self.guild else None
@@ -96,6 +100,8 @@ async def send(self,
96100
base["flags"] = 64
97101
else:
98102
base["data"]["flags"] = 64
103+
if hidden and embeds:
104+
self.slashcommand.logger.warning("You cannot use both `hidden` and `embeds`!")
99105
initial = True if not self.sent else False
100106
resp = await self._http.post(base, self._discord.user.id, self.interaction_id, self.__token, initial)
101107
self.sent = True

0 commit comments

Comments
 (0)