Skip to content

Commit 0d77578

Browse files
Merge branch 'master' into anothercat/files-in-edit
2 parents 7d649da + c107539 commit 0d77578

File tree

6 files changed

+55
-27
lines changed

6 files changed

+55
-27
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ What changes were made?
1313
- Issue:
1414
- [ ] This adds something new.
1515
- [ ] There is/are breaking change(s).
16-
- [ ] (If required) Relavent documentation has been updated/added.
16+
- [ ] (If required) Relevant documentation has been updated/added.
1717
- [ ] This is not a code change. (README, docs, etc.)

discord_slash/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
from .context import SlashContext
1414
from .utils import manage_commands
1515

16-
__version__ = "1.1.0"
16+
__version__ = "1.1.1"

discord_slash/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ async def sync_all_commands(self, delete_from_unused_guilds=False):
303303
cmds = await self.to_dict()
304304
self.logger.info("Syncing commands...")
305305
other_guilds = [x.id for x in self._discord.guilds if x.id not in cmds["guild"]]
306-
# This is an extremly bad way to do this, because slash cmds can be in guilds the bot isn't in
306+
# This is an extremely bad way to do this, because slash cmds can be in guilds the bot isn't in
307307
# But it's the only way until discord makes an endpoint to request all the guild with cmds registered.
308308

309309
await self.req.put_slash_commands(slash_commands=cmds["global"], guild_id=None)
@@ -838,5 +838,5 @@ async def on_slash_command_error(ctx, ex):
838838
if hasattr(self._discord, "on_slash_command_error"):
839839
self._discord.dispatch("slash_command_error", ctx, ex)
840840
return
841-
# Prints exception if not overrided or has no listener for error.
841+
# Prints exception if not overridden or has no listener for error.
842842
self.logger.exception(f"An exception has occurred while executing command `{ctx.name}`:")

discord_slash/context.py

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import typing
22
import asyncio
3+
from warnings import warn
4+
35
import discord
46
from contextlib import suppress
57
from discord.ext import commands
@@ -27,8 +29,8 @@ class SlashContext:
2729
:ivar bot: discord.py client.
2830
:ivar _http: :class:`.http.SlashCommandRequest` of the client.
2931
:ivar _logger: Logger instance.
30-
:ivar deffered: Whether the command is current deffered (loading state)
31-
:ivar _deffered_hidden: Internal var to check that state stays the same
32+
:ivar deferred: Whether the command is current deferred (loading state)
33+
:ivar _deferred_hidden: Internal var to check that state stays the same
3234
:ivar responded: Whether you have responded with a message to the interaction.
3335
:ivar guild_id: Guild ID of the command message. If the command was invoked in DM, then it is ``None``
3436
:ivar author_id: User ID representing author of the command message.
@@ -53,9 +55,9 @@ def __init__(self,
5355
self._http = _http
5456
self.bot = _discord
5557
self._logger = logger
56-
self.deffered = False
58+
self.deferred = False
5759
self.responded = False
58-
self._deffered_hidden = False # To check if the patch to the deffered response matches
60+
self._deferred_hidden = False # To check if the patch to the deferred response matches
5961
self.guild_id = int(_json["guild_id"]) if "guild_id" in _json.keys() else None
6062
self.author_id = int(_json["member"]["user"]["id"] if "member" in _json.keys() else _json["user"]["id"])
6163
self.channel_id = int(_json["channel_id"])
@@ -66,6 +68,26 @@ def __init__(self,
6668
else:
6769
self.author = discord.User(data=_json["user"], state=self.bot._connection)
6870

71+
@property
72+
def _deffered_hidden(self):
73+
warn("`_deffered_hidden` as been renamed to `_deferred_hidden`.", DeprecationWarning, stacklevel=2)
74+
return self._deferred_hidden
75+
76+
@_deffered_hidden.setter
77+
def _deffered_hidden(self, value):
78+
warn("`_deffered_hidden` as been renamed to `_deferred_hidden`.", DeprecationWarning, stacklevel=2)
79+
self._deferred_hidden = value
80+
81+
@property
82+
def deffered(self):
83+
warn("`deffered` as been renamed to `deferred`.", DeprecationWarning, stacklevel=2)
84+
return self.deferred
85+
86+
@deffered.setter
87+
def deffered(self, value):
88+
warn("`deffered` as been renamed to `deferred`.", DeprecationWarning, stacklevel=2)
89+
self.deferred = value
90+
6991
@property
7092
def guild(self) -> typing.Optional[discord.Guild]:
7193
"""
@@ -86,18 +108,18 @@ def channel(self) -> typing.Optional[typing.Union[discord.TextChannel, discord.D
86108

87109
async def defer(self, hidden: bool = False):
88110
"""
89-
'Deferes' the response, showing a loading state to the user
111+
'Defers' the response, showing a loading state to the user
90112
91-
:param hidden: Whether the deffered response should be ephemeral . Default ``False``.
113+
:param hidden: Whether the deferred response should be ephemeral . Default ``False``.
92114
"""
93-
if self.deffered or self.responded:
115+
if self.deferred or self.responded:
94116
raise error.AlreadyResponded("You have already responded to this command!")
95117
base = {"type": 5}
96118
if hidden:
97119
base["data"] = {"flags": 64}
98-
self._deffered_hidden = True
120+
self._deferred_hidden = True
99121
await self._http.post_initial_response(base, self.interaction_id, self.__token)
100-
self.deffered = True
122+
self.deferred = True
101123

102124
async def send(self,
103125
content: str = "", *,
@@ -167,20 +189,26 @@ async def send(self,
167189
if embeds or files:
168190
self._logger.warning("Embed/File is not supported for `hidden`!")
169191
base["flags"] = 64
170-
192+
171193
initial_message = False
172194
if not self.responded:
173195
initial_message = True
174-
if files and not self.deffered:
196+
if files and not self.defered:
175197
await self.defer(hidden=hidden)
176-
if self.deffered:
177-
if self._deffered_hidden != hidden:
198+
if self.defered:
199+
if self._defered_hidden != hidden:
200+
if files:
201+
raise error.IncorrectFormat("You cannot send files in the initial response!")
202+
if self.deferred:
203+
if self._deferred_hidden != hidden:
178204
self._logger.warning(
179-
"Deffered response might not be what you set it to! (hidden / visible) "
180-
"This is because it was deffered in a different state"
205+
"deferred response might not be what you set it to! (hidden / visible) "
206+
"This is because it was deferred in a different state"
181207
)
182208
resp = await self._http.edit(base, self.__token, files = files)
183-
self.deffered = False
209+
self.defered = False
210+
resp = await self._http.edit(base, self.__token)
211+
self.deferred = False
184212
else:
185213
json_data = {
186214
"type": 4,

docs/migration.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ This page contains instructions on how to migrate between versions with breaking
44

55
Migrate To V1.1.0
66
==================
7-
Changes that you'll need to make in this version are mainly becuase of a new ui from discord, more info `here <https://github.com/discord/discord-api-docs/pull/2615>`_
7+
Changes that you'll need to make in this version are mainly because of a new ui from discord, more info `here <https://github.com/discord/discord-api-docs/pull/2615>`_
88

99
Responding / Deferring
1010
**********************
1111

12-
In regards to :class:`SlashContext` the methods ``.respond`` and ``.ack`` have been removed, and ``.defer`` added.
12+
In regards to :class:`SlashContext` the methods ``.respond`` and ``.ack`` have been removed, and ``.defer`` added.
1313
Deferring a message will allow you to respond for up to 15 mins, but you'll have to defer within three seconds.
14-
When you defer the user will see a "this bot is thinking" message until you send a message, This message can be ephermical (hidden) or visible.
15-
``.defer`` has a ``hidden`` parameter, which will make the deferred message ephermical.
14+
When you defer the user will see a "this bot is thinking" message until you send a message, This message can be ephemeral (hidden) or visible.
15+
``.defer`` has a ``hidden`` parameter, which will make the deferred message ephemeral.
1616

1717
We suggest deferring if you might take more than three seconds to respond, but if you will call ``.send`` before three seconds then don't.
1818

@@ -33,7 +33,7 @@ Example
3333
async def command(ctx, ...):
3434
await ctx.respond()
3535
await ctx.send(...)
36-
36+
3737
# After 1
3838
@slash.slash(...)
3939
async def command(ctx, ...):
@@ -46,7 +46,7 @@ Example
4646
# Process that takes time
4747
await ctx.send(...)
4848
49-
49+
5050
Sending hidden messages
5151
***********************
5252
The method ``.send_hidden`` on :class:`SlashContext` has been removed. Use ``.send(hidden = True, ..)`` instead.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="discord-py-slash-command",
8-
version="1.1.0",
8+
version="1.1.1",
99
author="eunwoo1104",
1010
author_email="sions04@naver.com",
1111
description="A simple discord slash command handler for discord.py.",

0 commit comments

Comments
 (0)