Skip to content

Commit

Permalink
Fix autocomplete bug and make page sends awaitable
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodentman87 committed Aug 20, 2022
1 parent db6d620 commit db72869
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slashasaurus",
"version": "0.11.0",
"version": "0.11.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ export abstract class Page<
}

sendToChannel(channel: TextBasedChannel) {
this.client.sendPageToChannel(this, channel);
return this.client.sendPageToChannel(this, channel);
}

sendAsReply(
interaction: MessageComponentInteraction | CommandInteraction,
ephemeral = false
) {
this.client.replyToInteractionWithPage(this, interaction, ephemeral);
return this.client.replyToInteractionWithPage(this, interaction, ephemeral);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
12 changes: 11 additions & 1 deletion src/SlashasaurusClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,17 @@ export class SlashasaurusClient extends Client<true> {
}

private async handleAutocomplete(interaction: AutocompleteInteraction) {
const commandName = interaction.commandName;
let commandName = interaction.commandName;
// @ts-expect-error This is TS-private, but I know what I'm doing
if (interaction.options._group) {
// @ts-expect-error This is TS-private, but I know what I'm doing
commandName += '.' + interaction.options._group;
}
// @ts-expect-error This is TS-private, but I know what I'm doing
if (interaction.options._subcommand) {
// @ts-expect-error This is TS-private, but I know what I'm doing
commandName += '.' + interaction.options._subcommand;
}
const command = this.commandMap.get(commandName);
if (!command) {
interaction.respond([]);
Expand Down

0 comments on commit db72869

Please sign in to comment.