MessageCreate Event isn't working

This is the first listener Im creating I've read the documentation 50 times imo and checked out the examples and I am still confused
import { Events, Listener } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class UserEvent extends Listener<typeof Events.MessageCreate> {
public override async run(msg: Message) {
try {
this.container.logger.info(`Message sent by ${msg.author.username} in ${msg.guild?.name} (${msg.guildId})`);

} catch (error) {
this.container.logger.fatal(error);
}
}
}
import { Events, Listener } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class UserEvent extends Listener<typeof Events.MessageCreate> {
public override async run(msg: Message) {
try {
this.container.logger.info(`Message sent by ${msg.author.username} in ${msg.guild?.name} (${msg.guildId})`);

} catch (error) {
this.container.logger.fatal(error);
}
}
}
Solution:
you either have to name it messageCreate.<ext> or add a constructor with name: Events.MessageCreate (which resolves to name: 'messageCreate'
Jump to solution
5 Replies
BossDaily
BossDailyOP2y ago
NO error, or anything shows up in console
const client = new SapphireClient({
defaultPrefix: '!',
regexPrefix: /^(hey +)?bot[,! ]/i,
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Debug
},
shards: 'auto',
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Channel],
loadMessageCommandListeners: true
});
const client = new SapphireClient({
defaultPrefix: '!',
regexPrefix: /^(hey +)?bot[,! ]/i,
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Debug
},
shards: 'auto',
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Channel],
loadMessageCommandListeners: true
});
here is the client I have MessageContent intent
BossDaily
BossDailyOP2y ago
Favna
Favna2y ago
name of the file?
Solution
Favna
Favna2y ago
you either have to name it messageCreate.<ext> or add a constructor with name: Events.MessageCreate (which resolves to name: 'messageCreate'
BossDaily
BossDailyOP2y ago
it worked thx
Want results from more Discord servers?
Add your server