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

Few minor changes #94

Merged
merged 7 commits into from
Jan 22, 2025
Merged

Few minor changes #94

merged 7 commits into from
Jan 22, 2025

Conversation

Kyvrixon
Copy link
Contributor

  • Updated gitignore to ignore package-lock.json, you simply dont need that file in the repo.
  • Removed "engines" key from package.json as code works on v18 and later of Node.js perfectly fine.
  • Updated how "logsFileToChannel" feature so its more readable and visually appealing rather than a blob of text

One other thing I do recommend in the future is that you register slash commands before you login to the client as it can and does cause issues if the bot tries to register a new command for the guild, sometimes discord rejects it and the bot throws an error. Double registering can also occur (and has for me)

Kyvrixon and others added 3 commits January 21, 2025 19:37
- Updated gitignore to ignore package-lock.json
- Removed "engines" key from package.json as code works on v18 and later of Node.js just fine
- Updated how "logsFileToChannel" feature so its more readable and visually appealing rather than a blob of text

One other thing I do recommend in the future is that you register slash commands before you login to the client as it can and does cause issues if the bot tries to register a new command for the guild, sometimes discord rejects it and the bot throws an error. Double registering can also occur (and has for me)
Copy link
Owner

@ralphkb ralphkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Kyvrixon, thank you for your contribution but I will have to request a few changes before merging this PR.

Firstly, the package-lock.json file is important in my opinion for consistent builds and after reviewing a few articles about it I still think it should not be removed so please revert those changes.
Regarding the engines in package.json, it's not just about compatibility of the code with node versions but rather keeping track of the requirements of the dependencies. Currently some dependencies support only NodeJS 16 or above, soon will probably change to 18 and above etc. So the engines part of the file will enforce a node version that works if not now at least in the future so I will not remove it, should also be reverted back.

The change in error logging to make it easier to read is appreciated, that will be merged once you revert the other changes. Thank you.

On another note, please clarify the issue with registering slash commands. Currently the ready event responsible for that runs before the client logging in so I'm not sure what the issue is.

@Kyvrixon
Copy link
Contributor Author

Kyvrixon commented Jan 21, 2025

important in my opinion for consistent builds and after reviewing a few articles

The file gets overwritten and refreshed everytime you run npm install. It doesn't do anything with keeping consistant builds as long as everyone uses npm and the exact same package.json file. Yes, it can help but for a project like this where the current deps do not have breaking changes between versions (minus mongoose but that package still fully compatible even from minor and patch version updates), its fine to omit. What you read online is more assuming you are on a massive project with alot of deps especially those with breaking changes between minor version updates, not little projects like this.

So the engines part of the file will enforce a node version that works if not now at least in the future so I will not remove it, should also be reverted back.

I have fully tested every single feature and command and everything works perfectly fine with no issues on every major version from v18. I acknowledge the tracking with enforcing a version but seems to be a redundant restriction.

On another note, please clarify the issue with registering slash commands. Currently the ready event responsible for that runs before the client logging in so I'm not sure what the issue is.

Of course! The ready event executes when the client is fully online and ready - as you know, so after it logs in properly the event will be fired. This causes problems especially when registering new commands to a guild - usually uncached - (especially for the first time) there is quite a large chance that commands can be double registered and painstakingly hard to remove, and it has for me a couple of times until i roughly relocated that code logic to just above the event handler in bot.js, after that everything worked fine and discord didnt throw any errors and no commands were double registered. I would assume this either running twice without waiting for discords cache to get up to speed (explains the double registering) or its running as the client has logged in (which isnt recommended). I'll look into it futher later on in the week.
This isn't a groundbreaking issue but its something to keep aware of as the bot grows.

After reading all this, if you'd still like me to revert your requested changes im more than happy to ralph

@ralphkb
Copy link
Owner

ralphkb commented Jan 21, 2025

I understand your reasoning behind this but I would still appreciate the changes being reverted back. Regarding package-lock.json, I don't think it would cause any issues to keep it and since it might have benefits for some specific cases I'd like to have it here. Sometimes dependabot also updates and detects some vulnerable packages there and does an auto update for them, which helps me in my own local build as well since I then pull those changes locally haha.

The main goal of limiting to NodeJS 18 or above is to make sure no one installs the bot on much older versions like NodeJS 14 or 16 and it can always change in the future. I'm fine with keeping it to only NodeJS 18 and above.

About the registration of commands, I'm still not really sure about that part since I never encountered any issue with command registration nor had any reports of it having issues with any of the users of the bot. Feel free to make a PR or let me know if you think it can be improved in some way as I'm always open to such improvements of course!

Thanks again. 😄

@Kyvrixon Kyvrixon requested a review from ralphkb January 22, 2025 03:27
@Kyvrixon
Copy link
Contributor Author

No worries, I have reverted the changes. Do double check though

Copy link
Owner

@ralphkb ralphkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for your contributions!

@ralphkb ralphkb merged commit 5265fd0 into ralphkb:main Jan 22, 2025
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

Successfully merging this pull request may close these issues.

2 participants