Skip to content

Unhandled 'error' event emitted #10372

@Pyr33x

Description

@Pyr33x

Which package is this bug report for?

discord.js

Issue description

I've been trying to login to the bot client and faced this error:
~/projects/raytop/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:278 throw err; Error: Unhandled 'error' event emitted, received [object Object] at WebSocketShard.emit
Then I decided to try a template so maybe I could find a way:

  1. clone this Sapphire Typescript Starter which using sapphire framework on top of the discord.js
  2. try running pnpm start and you'll see ~/projects/raytop/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:278 throw err; Error: Unhandled 'error' event emitted, received [object Object] at WebSocketShard.emit
    This issue isn't coming from sapphire, cause I've even tried on discord.js itself and got the same result.

Code sample

import './lib/setup';

import { LogLevel, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';

const client = new SapphireClient({
	defaultPrefix: '!',
	caseInsensitiveCommands: true,
	logger: {
		level: LogLevel.Debug
	},
	intents: [GatewayIntentBits.DirectMessages, GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent],
	loadMessageCommandListeners: true
});

const main = async () => {
	try {
		client.logger.info('Logging in');
		await client.login();
		client.logger.info('logged in');
	} catch (error) {
		client.logger.fatal(error);
		await client.destroy();
		process.exit(1);
	}
};

void main();

Versions

  • Discord.js: ^14.14.1
  • @Sapphire/framework: ^5.0.7
  • Typescript: ~5.4.5

Issue priority

High (immediate attention needed)

Which partials do you have configured?

User

Which gateway intents are you subscribing to?

Guilds, GuildMessages, DirectMessages, MessageContent

I have tested this issue on a development release

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions