discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.2k stars 3.96k forks source link

UnsupportedCacheOverwriteWarning when using TSX #9770

Closed SomeAspy closed 11 months ago

SomeAspy commented 1 year ago

Which package is this bug report for?

discord.js

Issue description

When using TSX as opposed to building with TSC or running with TS-Node, TSX renames the Collection class to _Collection which triggers the UnsupportedCacheOverwriteWarning warning.

This is reproducible by running TS code with TSX

  1. Use any discord TS bot.
  2. Use TSX to run the code.
  3. Warnings will manifest.

Code sample

import {
    Client,
    GatewayIntentBits,
    Events,
} from 'discord.js';
import credentials from './config/credentials.json' assert { type: 'json' };

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once)
// We use 'c' for the event parameter to keep it separate from the already defined 'client'
client.once(Events.ClientReady, (c) => {
    console.log(`Ready! Logged in as ${c.user.tag}`);
    console.log(client.guilds.cache.constructor.name); // will log "_Collection" when using TSX
});

// Log in to Discord with your client's token
client.login(credentials.DiscordToken);

Versions

Issue priority

Low (slightly annoying)

Which partials do you have configured?

Not applicable

Which gateway intents are you subscribing to?

Not applicable

I have tested this issue on a development release

9ed1b59df

Lemonaut commented 1 year ago

i also use TSX and this warning only seems to have popped up today when i updated to discord.js from v14.11 to v14.13

filename24 commented 12 months ago

builded js file a same errors

SuperchupuDev commented 12 months ago

this does not happen to me anymore in tsx 3.12.8

SomeAspy commented 11 months ago

This appears to be fixed- Thanks guys!