refactor: rename events to be consistent with WS names (#6010)

Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
Antonio Román
2021-07-03 14:23:53 +02:00
committed by GitHub
parent 7dd1a8da08
commit a11a10525b
13 changed files with 50 additions and 83 deletions

View File

@@ -4,6 +4,8 @@ const Action = require('./Action');
const { Events, InteractionTypes, MessageComponentTypes } = require('../../util/Constants');
const Structures = require('../../util/Structures');
let deprecationEmitted = false;
class InteractionCreateAction extends Action {
handle(data) {
const client = this.client;
@@ -37,12 +39,25 @@ class InteractionCreateAction extends Action {
return;
}
const interaction = new InteractionType(client, data);
/**
* Emitted when an interaction is created.
* @event Client#interactionCreate
* @param {Interaction} interaction The interaction which was created
*/
client.emit(Events.INTERACTION_CREATE, interaction);
/**
* Emitted when an interaction is created.
* @event Client#interaction
* @param {Interaction} interaction The interaction which was created
* @deprecated Use {@link Client#interactionCreate} instead
*/
client.emit(Events.INTERACTION_CREATE, new InteractionType(client, data));
if (client.emit('interaction', interaction) && !deprecationEmitted) {
deprecationEmitted = true;
process.emitWarning('The interaction event is deprecated. Use interactionCreate instead', 'DeprecationWarning');
}
}
}

View File

@@ -3,6 +3,8 @@
const Action = require('./Action');
const { Events } = require('../../util/Constants');
let deprecationEmitted = false;
class MessageCreateAction extends Action {
handle(data) {
const client = this.client;
@@ -25,10 +27,22 @@ class MessageCreateAction extends Action {
/**
* Emitted whenever a message is created.
* @event Client#message
* @event Client#messageCreate
* @param {Message} message The created message
*/
client.emit(Events.MESSAGE_CREATE, message);
/**
* Emitted whenever a message is created.
* @event Client#message
* @param {Message} message The created message
* @deprecated Use {@link Client#messageCreate} instead
*/
if (client.emit('message', message) && !deprecationEmitted) {
deprecationEmitted = true;
process.emitWarning('The message event is deprecated. Use messageCreate instead', 'DeprecationWarning');
}
return { message };
}