Skip to content

Commit

Permalink
Only update perms for guild commands, not global
Browse files Browse the repository at this point in the history
  • Loading branch information
breqdev committed Apr 28, 2022
1 parent 96e339a commit e6887b0
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions flask_discord_interactions/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,23 +422,24 @@ def update_commands(self, app=None, guild_id=None):
for command in app.discord_commands.values():
command.id = command.name

for command in app.discord_commands.values():
if not app.config["DONT_REGISTER_WITH_DISCORD"]:
response = requests.put(
url + "/" + command.id + "/permissions",
json={"permissions": command.dump_permissions()},
headers=self.auth_headers(app),
)

try:
response.raise_for_status()
except requests.exceptions.HTTPError:
raise ValueError(
f"Unable to register permissions for {command.id}:"
f"{response.status_code} {response.text}"
if guild_id:
for command in app.discord_commands.values():
if not app.config["DONT_REGISTER_WITH_DISCORD"]:
response = requests.put(
url + "/" + command.id + "/permissions",
json={"permissions": command.dump_permissions()},
headers=self.auth_headers(app),
)

self.throttle(response)
try:
response.raise_for_status()
except requests.exceptions.HTTPError:
raise ValueError(
f"Unable to register permissions for {command.id}:"
f"{response.status_code} {response.text}"
)

self.throttle(response)

def update_slash_commands(self, *args, **kwargs):
"""
Expand Down

0 comments on commit e6887b0

Please sign in to comment.