Skip to content

Commit 85c1820

Browse files
Fix incorrect url and bugs in manage_commands
Add missing /commands to some permission endpoints Update permissions functions descriptions Fix bug that calls the wrong function if there's a ratelimit Fixes: #198
1 parent af5c23e commit 85c1820

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

discord_slash/utils/manage_commands.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ async def get_all_guild_commands_permissions(bot_id,
147147
bot_token,
148148
guild_id):
149149
"""
150-
A coroutine that sends a slash command get request to Discord API.
150+
A coroutine that sends a gets all the commands permissions for that guild.
151151
152152
:param bot_id: User ID of the bot.
153153
:param bot_token: Token of the bot.
154154
:param guild_id: ID of the guild to get permissions.
155155
:return: JSON Response of the request. A list of <https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions>.
156156
:raises: :class:`.error.RequestFailure` - Requesting to Discord API has failed.
157157
"""
158-
url = f"https://discord.com/api/v8/applications/{bot_id}/guilds/{guild_id}/permissions"
158+
url = f"https://discord.com/api/v8/applications/{bot_id}/guilds/{guild_id}/commands/permissions"
159159
async with aiohttp.ClientSession() as session:
160160
async with session.get(url, headers={"Authorization": f"Bot {bot_token}"}) as resp:
161161
if resp.status == 429:
@@ -165,15 +165,15 @@ async def get_all_guild_commands_permissions(bot_id,
165165
if not 200 <= resp.status < 300:
166166
raise RequestFailure(resp.status, await resp.text())
167167
return await resp.json()
168-
168+
169169

170170
async def update_single_command_permissions(bot_id,
171171
bot_token,
172172
guild_id,
173173
command_id,
174174
permissions):
175175
"""
176-
A coroutine that sends a slash command put request to Discord API.
176+
A coroutine that sends a request to update a single command's permissions in guild
177177
178178
:param bot_id: User ID of the bot.
179179
:param bot_token: Token of the bot.
@@ -189,18 +189,19 @@ async def update_single_command_permissions(bot_id,
189189
if resp.status == 429:
190190
_json = await resp.json()
191191
await asyncio.sleep(_json["retry_after"])
192-
return await update_guild_commands_permissions(bot_id, bot_token, guild_id, permissions)
192+
return await update_single_command_permissions(bot_id, bot_token, guild_id, permissions)
193193
if not 200 <= resp.status < 300:
194194
raise RequestFailure(resp.status, await resp.text())
195195
return await resp.json()
196196

197197

198+
198199
async def update_guild_commands_permissions(bot_id,
199200
bot_token,
200201
guild_id,
201202
cmd_permissions):
202203
"""
203-
A coroutine that sends a slash command put request to Discord API.
204+
A coroutine that updates permissions for all commands in a guild.
204205
205206
:param bot_id: User ID of the bot.
206207
:param bot_token: Token of the bot.
@@ -209,7 +210,7 @@ async def update_guild_commands_permissions(bot_id,
209210
:return: JSON Response of the request. A list of <https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions>.
210211
:raises: :class:`.error.RequestFailure` - Requesting to Discord API has failed.
211212
"""
212-
url = f"https://discord.com/api/v8/applications/{bot_id}/guilds/{guild_id}/permissions"
213+
url = f"https://discord.com/api/v8/applications/{bot_id}/guilds/{guild_id}/commands/permissions"
213214
async with aiohttp.ClientSession() as session:
214215
async with session.put(url, headers={"Authorization": f"Bot {bot_token}"}, json=cmd_permissions) as resp:
215216
if resp.status == 429:

0 commit comments

Comments
 (0)