Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(MessageCreate): remove message event #6324

Merged
merged 3 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions packages/discord.js/src/client/actions/MessageCreate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
'use strict';

const process = require('node:process');
const Action = require('./Action');
const { Events } = require('../../util/Constants');

let deprecationEmitted = false;

class MessageCreateAction extends Action {
handle(data) {
const client = this.client;
Expand All @@ -25,17 +22,6 @@ class MessageCreateAction extends Action {
*/
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#event:messageCreate} instead
*/
if (client.emit('message', message) && !deprecationEmitted) {
deprecationEmitted = true;
process.emitWarning('The message event is deprecated. Use messageCreate instead', 'DeprecationWarning');
}

return { message };
}

Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/test/tester2000.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const commands = {
ping: message => message.channel.send('pong'),
};

client.on('message', message => {
client.on('messageCreate', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

message.content = message.content.replace(prefix, '').trim().split(' ');
Expand Down
2 changes: 0 additions & 2 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3899,8 +3899,6 @@ export interface ClientEvents extends BaseClientEvents {
guildUpdate: [oldGuild: Guild, newGuild: Guild];
inviteCreate: [invite: Invite];
inviteDelete: [invite: Invite];
/** @deprecated Use messageCreate instead */
message: [message: Message];
messageCreate: [message: Message];
messageDelete: [message: Message | PartialMessage];
messageReactionRemoveAll: [
Expand Down