Added warning when use both `hidden` and `embeds`
@@ -3,6 +3,7 @@ import discord
from discord.ext import commands
from . import http
from . import error
+from .client import SlashCommand
class SlashContext:
@@ -18,6 +19,7 @@ class SlashContext:
:ivar command_id: ID of the command.
:ivar _http: :class:`.http.SlashCommandRequest` of the client.
:ivar _discord: :class:`discord.ext.commands.Bot`
+ :ivar slashcommand: :class:`.client.SlashCommand`
:ivar sent: Whether you sent the initial response.
:ivar guild: :class:`discord.Guild` instance of the command message.
:ivar author: :class:`discord.Member` instance representing author of the command message.
@@ -27,13 +29,15 @@ class SlashContext:
def __init__(self,
_http: http.SlashCommandRequest,
_json: dict,
- _discord: typing.Union[discord.Client, commands.Bot]):
+ _discord: typing.Union[discord.Client, commands.Bot],
+ slashcommand: SlashCommand):
self.__token = _json["token"]
self.name = _json["data"]["name"]
self.interaction_id = _json["id"]
self.command_id = _json["data"]["id"]
self._http = _http
self._discord = _discord
+ self.slashcommand = slashcommand
self.sent = False
self.guild: discord.Guild = _discord.get_guild(int(_json["guild_id"]))
self.author: discord.Member = self.guild.get_member(int(_json["member"]["user"]["id"])) if self.guild else None
@@ -96,6 +100,8 @@ class SlashContext:
base["flags"] = 64
else:
base["data"]["flags"] = 64
+ if hidden and embeds:
+ self.slashcommand.logger.warning("You cannot use both `hidden` and `embeds`!")
initial = True if not self.sent else False
resp = await self._http.post(base, self._discord.user.id, self.interaction_id, self.__token, initial)
self.sent = True
