import { Events } from "discord.js";
import CustomApplication from "./app";
import { EventType, EventOptions } from "../types";
export default class Event implements EventType {
client: CustomApplication;
name: Events;
description: string;
once: boolean;
constructor(client: CustomApplication, options: EventOptions) {
this.client = client;
this.name = options.name;
this.description = options.description;
this.once = options.once
}
execute(...args: any): void {};
}
#How can I avoid using any here
20 messages · Page 1 of 1 (latest)
- 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
How can I avoid using any type in my execute function
Please ping me if you know the solution
by using the type that function is supposed to return
i dont know what that is because its not my code
no like does discord.js offers any types
? type for what
import type { ClientEvents } from "discord.js";
import CustomClient from "../Classes/CustomClient/CustomClient.js";
export class Event<event extends keyof ClientEvents> {
public readonly event: event;
public readonly once?: boolean;
public readonly run: (client: CustomClient, ...args: ClientEvents[event]) => Promise<any>;
public constructor(eventData: Event<event>) {
this.event = eventData.event;
this.once = eventData.once;
this.run = eventData.run;
}
}
I use this if it helps, you can use the event name with djs's client events
so on every event i have to use ClientEvent
if i remove the any
right?
what..?
You only have to use ClientEvents on the definition of your type/class. For the specific instances of events it would be inferred then
ty I fixed it kind off
You‘d probably need the Event generic on your EventOptions too to infer from name
yes
Perfect