-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐ | [v14 UPGRADE] Discord.JS v14 Template (#17)
Update Packages Update Template Core Files Update Legacy Commands/Handler Update Slash Commands/Handler Update Context Menu Commands/Handler Update Select Menu Commands/Handler Update Buttons/Handler Update Modals/Handler [NEW] Autocomplete Handler Co-authored-by: Fiezt <[email protected]>
- Loading branch information
1 parent
8ff9646
commit 5575ea9
Showing
19 changed files
with
425 additions
and
4,009 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 was deleted.
Oops, something went wrong.
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
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,48 @@ | ||
/** | ||
* @file Autocomplete Interaction Handler | ||
* @author Naman Vrati | ||
* @since 3.3.0 | ||
* @version 3.3.0 | ||
*/ | ||
|
||
const { InteractionType } = require("discord-api-types/v9"); | ||
|
||
module.exports = { | ||
name: "interactionCreate", | ||
|
||
/** | ||
* @description Executes when an interaction is created and handle it. | ||
* @author Naman Vrati | ||
* @param {import('discord.js').AutocompleteInteraction & { client: import('../typings').Client }} interaction The interaction which was created | ||
*/ | ||
|
||
async execute(interaction) { | ||
// Deconstructed client from interaction object. | ||
const { client } = interaction; | ||
|
||
// Checks if the interaction is a request (to prevent weird bugs) | ||
|
||
if (interaction.type === InteractionType.ApplicationCommandAutocomplete) | ||
return; | ||
|
||
// Checks if the request is available in our code. | ||
|
||
const request = client.autocompleteInteractions.get( | ||
interaction.commandName | ||
); | ||
|
||
// If the interaction is not a request in cache. | ||
|
||
if (!request) return; | ||
|
||
// A try to executes the interaction. | ||
|
||
try { | ||
await request.execute(interaction); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
|
||
return; | ||
}, | ||
}; |
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
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
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
Oops, something went wrong.