X is not a constructor but works at other parts of the code?

Okay so im a little helpless here. Im currently rebuilding my entire bot, and so decided to go for typescript and the newest discord.js version. All good all fine, until i stumbled upon this issue, which will be described here: I have a Class called "Command" that holds all the callbacks and variables needed for Command Registration later. I have a Class called "CommandRegister" which will register Commands for the respective guilds. I have a Class called "Localisation" which stores all translated strings for supported languages. Now the issue: while looping through all guilds the bot is part of, and picking the preferredLocale of the guild, im attempting to translate the command (description) based on the locale. However, whenever im attempting to create a new Localisation instance,
tsc
tsc
keeps telling me that the "Localisation" is not a constructor, while im calling it in the same way in other parts of the bot without issues?` In here in the provided and necessary code:
// Class definition for a Command (Discord)
import { Localisation } from "../../localisation/Localisation";
import {ChatInputCommandInteraction, Guild} from "discord.js";

export class Command {

// Name of the command
private readonly name: string;

// Description of the command
private description: string;

...

// Commands own localisation
private localisation: Localisation;


constructor(name: string, description: string)
{
this.name = this.formatName(name);
this.description = description;
this.localisation = new Localisation(); // <- THIS THROWS THE ERROR
}

...
}
// Class definition for a Command (Discord)
import { Localisation } from "../../localisation/Localisation";
import {ChatInputCommandInteraction, Guild} from "discord.js";

export class Command {

// Name of the command
private readonly name: string;

// Description of the command
private description: string;

...

// Commands own localisation
private localisation: Localisation;


constructor(name: string, description: string)
{
this.name = this.formatName(name);
this.description = description;
this.localisation = new Localisation(); // <- THIS THROWS THE ERROR
}

...
}
export class Localisation {
...
}
export class Localisation {
...
}
Im lowkey clueless, any help appreciated.
1 Reply
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Want results from more Discord servers?
Add your server