montri
montri
DIAdiscord.js - Imagine an app
Created by montri on 5/4/2024 in #djs-questions
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.
2 replies
DIAdiscord.js - Imagine an app
Created by montri on 1/19/2023 in #djs-questions
deleting/hiding message within channel for specific user
Hey, just asking if there is a way for bot to hide/delete a message within a single channel from a specific user within that channel? It is not based on slash commands and
interaction.reply
interaction.reply
6 replies