Skip to content

Commit

Permalink
Edited get slash commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Shell1010 committed Jan 22, 2024
1 parent 8e1135a commit 5d98397
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions selfcord/models/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async def delayed_delete(self, message, time):
await asyncio.sleep(time)
await message.delete()

async def get_slash_commands(self):
async def get_slash_commands(self, name: Optional[str] = None) -> Optional[SlashCommand] | Optional[list[SlashCommand]]:
if self.guild_id is not None:
json = await self.http.request(
"GET", f"/guilds/{self.guild_id}/application-command-index"
Expand All @@ -203,7 +203,10 @@ async def get_slash_commands(self):
if cmd.get("guild_id") is None:
cmd.update({"guild_id": self.guild_id})
cmds.append(SlashCommand(cmd, self.bot))

if name is not None:
for cmd in cmds:
if cmd.name == name:
return cmd
return cmds

async def trigger_slash(self, cmd: SlashCommand):
Expand Down

0 comments on commit 5d98397

Please sign in to comment.