Poulette
Poulette
DIAdiscord.js - Imagine an app
Created by Poulette on 8/3/2023 in #djs-questions
Change TS type of Client
I've made some changes to the default Client by adding a config file and some collections. While this all works I can't figure out a way to change the type of the Client so it reflects my changes. Here's som of my code
export default class MCSSBot extends Client {
public config: Config
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public commandCollection: Collection<string, any> = new Collection();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public eventCollection: Collection<string, any> = new Collection();
}
export default class MCSSBot extends Client {
public config: Config
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public commandCollection: Collection<string, any> = new Collection();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public eventCollection: Collection<string, any> = new Collection();
}
I've tried adding a TS file as follows but it causes more issues that it solves
declare module "discord.js" {
export interface Client {
config: Config
commandCollection: Collection<string, any> = new Collection();
eventCollection: Collection<string, any> = new Collection();
}
}
declare module "discord.js" {
export interface Client {
config: Config
commandCollection: Collection<string, any> = new Collection();
eventCollection: Collection<string, any> = new Collection();
}
}
I understand why the issues exist but not how I can fix them
6 replies
DIAdiscord.js - Imagine an app
Created by Poulette on 5/13/2023 in #djs-questions
Asynchronous user fetching causing issues with embeds and buttons
Hi, I'm using redis to track the number of messages a user has sent in a thread and I store it in a hash using the userid as the key. I'm trying to get the user's name to use it as the label for a button. My code goes over an array of IDs and for each ID it grabs the username and adds a button to an actionrow. The cache is undefined for some reason so I'm using interaction.guild?.members.fetch(<user id>). The issue being that awaiting that method causes some weird issues (see the pastebin) and not awaiting it returns nothing as expected. The function it's in is async... https://pastebin.com/t4sdXMTp
46 replies