Skip to content

Commit 0c7df22

Browse files
authored
Merge pull request #105 from robotic-coder/master
Fixes and optimisations mainly for guilds with only the applications.commands scope
2 parents 6955da8 + 7812a1d commit 0c7df22

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

discord_slash/client.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,8 @@ async def on_socket_response(self, msg):
722722

723723
selected_cmd = self.commands[to_use["data"]["name"]]
724724

725-
if selected_cmd.allowed_guild_ids:
726-
guild_id = ctx.guild.id if isinstance(ctx.guild, discord.Guild) else ctx.guild
727-
728-
if guild_id not in selected_cmd.allowed_guild_ids:
729-
return
725+
if selected_cmd.allowed_guild_ids and ctx.guild_id not in selected_cmd.allowed_guild_ids:
726+
return
730727

731728
if selected_cmd.has_subcommands and not selected_cmd.func:
732729
return await self.handle_subcommand(ctx, to_use)

discord_slash/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def respond(self, eat: bool = False):
9191
base = {"type": 2 if eat else 5}
9292
_task = self.bot.loop.create_task(self._http.post(base, self.interaction_id, self.__token, True))
9393
self.sent = True
94-
if not eat:
94+
if not eat and (not self.guild_id or (self.channel and self.channel.permissions_for(self.guild.me).view_channel)):
9595
with suppress(asyncio.TimeoutError):
9696
def check(message: discord.Message):
9797
user_id = self.author_id
@@ -184,7 +184,7 @@ async def send(self,
184184
resp = await self._http.post(base, self.interaction_id, self.__token, files=files)
185185
smsg = model.SlashMessage(state=self.bot._connection,
186186
data=resp,
187-
channel=self.channel or discord.Object(id=self.channel),
187+
channel=self.channel or discord.Object(id=self.channel_id),
188188
_http=self._http,
189189
interaction_token=self.__token)
190190
if delete_after:

0 commit comments

Comments
 (0)