Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
68 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import type { Interaction } from "discord.js"; | ||
import type { ShewenyClient } from "../client/Client"; | ||
import type { Interaction } from 'discord.js'; | ||
import type { ShewenyClient } from '../client/Client'; | ||
|
||
export default function run(client: ShewenyClient, interaction: Interaction) { | ||
if (interaction.isButton()) return client.emit("interactionButtonCreate", interaction); | ||
if (interaction.isButton()) return client.emit('interactionButtonCreate', interaction); | ||
|
||
if (interaction.isCommand() || interaction.isContextMenu()) | ||
return client.emit("interactionCommandCreate", interaction); | ||
if (interaction.isCommand() || interaction.isContextMenu()) return client.emit('interactionCommandCreate', interaction); | ||
|
||
if (interaction.isContextMenu()) | ||
return client.emit("interactionContextMenuCreate", interaction); | ||
if (interaction.isCommand() || interaction.isContextMenu() || interaction.isAutocomplete()) | ||
return client.emit('interactionCommandOrAutocompleteCreate', interaction); | ||
|
||
if (interaction.isSelectMenu()) | ||
return client.emit("interactionSelectMenuCreate", interaction); | ||
if (interaction.isContextMenu()) return client.emit('interactionContextMenuCreate', interaction); | ||
|
||
if (interaction.isMessageComponent()) | ||
return client.emit("interactionMessageComponentCreate", interaction); | ||
if (interaction.isSelectMenu()) return client.emit('interactionSelectMenuCreate', interaction); | ||
|
||
if (interaction.isMessageComponent()) return client.emit('interactionMessageComponentCreate', interaction); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Command, ShewenyClient } from '../../../../'; | ||
import type { AutocompleteInteraction, CommandInteraction } from 'discord.js'; | ||
|
||
export class PingCommand extends Command { | ||
constructor(client: ShewenyClient) { | ||
super(client, { | ||
name: 'autocomplete', | ||
description: 'Test the autocomplete', | ||
type: 'SLASH_COMMAND', | ||
category: 'Misc', | ||
options: [ | ||
{ name: 'name', description: 'description', type: 'STRING', autocomplete: true }, | ||
{ name: 'theme', description: 'description', type: 'STRING', autocomplete: true }, | ||
], | ||
}); | ||
} | ||
execute(interaction: CommandInteraction) { | ||
interaction.reply('Autocomplete work !'); | ||
} | ||
onAutocomplete(interaction: AutocompleteInteraction) { | ||
const focusedOption = interaction.options.getFocused(true); | ||
|
||
let choices: any; | ||
|
||
if (focusedOption.name === 'name') { | ||
choices = ['faq', 'install', 'collection', 'promise', 'debug']; | ||
} | ||
|
||
if (focusedOption.name === 'theme') { | ||
choices = ['halloween', 'christmas', 'summer']; | ||
} | ||
|
||
const filtered = choices!.filter((choice: any) => choice.startsWith(focusedOption.value)); | ||
interaction | ||
.respond(filtered.map((choice: any) => ({ name: choice, value: choice }))) | ||
.then(console.log) | ||
.catch(console.error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { AutocompleteInteraction } from 'discord.js'; | ||
import type { ShewenyClient } from '..'; | ||
import type { CommandInteraction, ContextMenuInteraction } from 'discord.js'; | ||
export default function run(client: ShewenyClient, interaction: CommandInteraction | ContextMenuInteraction | AutocompleteInteraction): Promise<any>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import type { Interaction } from "discord.js"; | ||
import type { ShewenyClient } from "../client/Client"; | ||
import type { Interaction } from 'discord.js'; | ||
import type { ShewenyClient } from '../client/Client'; | ||
export default function run(client: ShewenyClient, interaction: Interaction): boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters