Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.ts Not Detecting Commands with Hot Reload #10

Open
joshuanianji opened this issue Dec 23, 2021 · 1 comment
Open

client.ts Not Detecting Commands with Hot Reload #10

joshuanianji opened this issue Dec 23, 2021 · 1 comment

Comments

@joshuanianji
Copy link

Hey, thanks for this template!

I recently started using this repo and noticed that the commands weren't registering, and when i looked into client/client.ts, I realized it was filtering .js files instead of .ts files.

Example:

const cmds = readdirSync(`${commandPath}/${dir}`).filter((file) => file.endsWith(".js"));

Changing it to .ts fixes it for me, and it looks like most of the readdirSync functions look for .js extensions.

This is a pretty small fix so I just wanted to let you know, but if you want I can definitely submit a PR!

@joshuanianji
Copy link
Author

Oops, just realized this was because ts-node-dev for my live reload; the commands will obviously work after running tsc lol.

I ended up adding both .ts and .js checks to the code, like so:

const cmds = readdirSync(`${commandPath}/${dir}`).filter((file) => file.endsWith(".js") || file.endsWith(".ts"));

I was thinking we could also use an environment variable to check if it's a dev environment with hot reload enabled.

Do you think these changes are worthwhile? I'll change the title to better reflect this issue now.

@joshuanianji joshuanianji changed the title client.ts Not Detecting Commands client.ts Not Detecting Commands with Hot Reload Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant