refactor(Interaction): See description
- Change the data returned when interacting, from `nonce: Snowflake` to `data: InteractionResponseBody` (use try catch to detect command errors) - Full support for Autocomplete (Automatically selects the first option)
This commit is contained in:
@@ -19,5 +19,5 @@ module.exports = (client, { d: data }) => {
|
||||
* @param {AutocompleteResponse} data Data
|
||||
* @deprecated Test only
|
||||
*/
|
||||
client.emit(Events.DEBUG, data);
|
||||
client.emit(Events.APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, data);
|
||||
};
|
||||
|
@@ -8,6 +8,9 @@ const { Events } = require('../../../util/Constants');
|
||||
*/
|
||||
|
||||
module.exports = (client, packet) => {
|
||||
if (client.user.bot) client.actions.InteractionCreate.handle(packet.d);
|
||||
else client.emit(Events.INTERACTION_CREATE, packet.d);
|
||||
if (client.user.bot) {
|
||||
client.actions.InteractionCreate.handle(packet.d);
|
||||
} else {
|
||||
client.emit(Events.INTERACTION_CREATE, packet.d);
|
||||
}
|
||||
};
|
||||
|
@@ -8,4 +8,8 @@ module.exports = (client, { d: data }) => {
|
||||
* @param {InteractionResponseBody} data data
|
||||
*/
|
||||
client.emit(Events.INTERACTION_FAILURE, data);
|
||||
client.emit('interactionResponse', {
|
||||
status: false,
|
||||
metadata: data,
|
||||
});
|
||||
};
|
||||
|
@@ -8,4 +8,8 @@ module.exports = (client, { d: data }) => {
|
||||
* @param {InteractionResponseBody} data data
|
||||
*/
|
||||
client.emit(Events.INTERACTION_SUCCESS, data);
|
||||
client.emit('interactionResponse', {
|
||||
status: true,
|
||||
metadata: data,
|
||||
});
|
||||
};
|
||||
|
@@ -5,6 +5,7 @@ const handlers = Object.fromEntries([
|
||||
['RESUMED', require('./RESUMED')],
|
||||
['RELATIONSHIP_ADD', require('./RELATIONSHIP_ADD')],
|
||||
['RELATIONSHIP_REMOVE', require('./RELATIONSHIP_REMOVE')],
|
||||
['APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE', require('./APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE')],
|
||||
['APPLICATION_COMMAND_CREATE', require('./APPLICATION_COMMAND_CREATE')],
|
||||
['APPLICATION_COMMAND_DELETE', require('./APPLICATION_COMMAND_DELETE')],
|
||||
['APPLICATION_COMMAND_UPDATE', require('./APPLICATION_COMMAND_UPDATE')],
|
||||
|
Reference in New Issue
Block a user