Update dependencies, remote unnecessary RwLock on database, fix typos #43

Closed
cordlesscoder wants to merge 8 commits from cordlesscoder/discord-bot:main into main
Contributor
No description provided.
cordlesscoder added 2 commits 2025-09-11 08:18:22 +00:00
Fix typos
Some checks failed
/ check_lfs (pull_request) Successful in 5s
/ lint_fmt (pull_request) Failing after 14s
/ lint_clippy (pull_request) Failing after 11s
/ build (pull_request) Has been skipped
4b4e5cb289
cordlesscoder reviewed 2025-09-11 08:43:54 +00:00
@ -163,3 +153,1 @@
//? maybe handle this and possibly throw error if its none
let _ = resvg::render(&tree, usvg::FitTo::Size(self.size.0, self.size.1), tiny_skia::Transform::default(), pixmap.as_mut());
resvg::render(&tree, usvg::Transform::default().post_scale(scale, scale), &mut pixmap.as_mut());
Author
Contributor

Please double check this replacement logic for FitTo

Please double check this replacement logic for FitTo
Owner

Read the top comment on this page, then decide what ye want to do.

Read the top comment on this page, then decide what ye want to do.
silver requested changes 2025-09-11 09:03:42 +00:00
silver left a comment
Owner

Overall its pretty good.
You clearly dont like typos though.

Seems like updating the dependencies lead ye to write code ye didn't understand.
Can ye stand over it?
If ye cant then have a think about it.

Honestly would be really nice to have the rwlock removed, at teh time I was writing it originally it was shouting at me until I added it.
Good to see that it has changed since.

.unwrap() is useful for testing but having it in prod leads to not correctly handling the errors.

Overall its pretty good. You clearly dont like typos though. Seems like updating the dependencies lead ye to write code ye didn't understand. Can ye stand over it? If ye cant then have a think about it. Honestly would be really nice to have the rwlock removed, at teh time I was writing it originally it was shouting at me until I added it. Good to see that it has changed since. ``.unwrap()`` is useful for testing but having it in prod leads to not correctly handling the errors.
.rustfmt.toml Outdated
@ -7,4 +7,5 @@ fn_params_layout = "Compressed"
struct_lit_width = 0
tab_spaces = 2
use_small_heuristics = "Max"
imports_granularity = "Crate"
Owner

Why disable this?

Why disable this?
Author
Contributor

It isn't available in stable rustfmt, it's still a nightly feature

It isn't available in stable rustfmt, it's still a [nightly feature](https://github.com/rust-lang/rustfmt/issues/4991)
Owner

I am aware, throws out some logging if ye are on stable, but does not cause any errors in pipeline

I am aware, throws out some logging if ye are on stable, but does not cause any errors in pipeline
cordlesscoder marked this conversation as resolved
Cargo.toml Outdated
@ -22,3 +22,3 @@
[dependencies]
# discord library
serenity = { version = "0.12", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "cache"] }
serenity = { version = "0.12", default-features = false, features = [
Owner

Dont do this.

More specifically if ye want it to look prettier then ye use the alternate format, not formatting it like this.

Dont do this. More specifically if ye want it to look prettier then ye use the alternate format, not formatting it like this.
Author
Contributor

I didn't do this, my TOML formatter did(taplo). That's the dark side of enabling format on save :(

I didn't do this, my TOML formatter did(taplo). That's the dark side of enabling format on save :(
Owner

Not quite sorted yet, for a hint as to why the single line stuff is better for this use case look at wolves_oxidized.

Not quite sorted yet, for a hint as to why the single line stuff is better for this use case look at ``wolves_oxidized``.
Cargo.toml Outdated
@ -48,3 +56,3 @@
maud = "0.27"
toml = "0.8.23"
toml = "0.9.5"
Owner

Is there any reason to update?

  • Some missing function that ye want?
  • Issue with a CVE?
  • Ye just want to make a change for the sake of making a change?
Is there any reason to update? * Some missing function that ye want? * Issue with a CVE? * Ye just want to make a change for the sake of making a change?
Author
Contributor

https://github.com/toml-rs/toml/blob/main/crates/toml/CHANGELOG.md#092---2025-07-11
That fixes an infinite loop on certain invalid TOML inputs

https://github.com/toml-rs/toml/blob/main/crates/toml/CHANGELOG.md#092---2025-07-11 That fixes an infinite loop on certain invalid TOML inputs
Owner

from the 9.0 notes:

New TOML parser and writer which carries a risk for regressions

joys of a major bump, so not really a too valid answer for this case.
Not to mention bumping teh image dependencies brought its own issues.

from the 9.0 notes: > New TOML parser and writer which carries a risk for regressions joys of a major bump, so not really a too valid answer for this case. Not to mention bumping teh image dependencies brought its own issues.
Author
Contributor

The major bump happened 2 months ago and the TOML crate is ridiculously popular - I believe it's reasonable enough to assume that any regressions have been found and fixed.
The image dependencies were 2 years out of date and therefore missing support for many SVG features, e.g. color emojis.

The major bump happened 2 months ago and the TOML crate is ridiculously popular - I believe it's reasonable enough to assume that any regressions have been found and fixed. The image dependencies were 2 years out of date and therefore missing support for many SVG features, e.g. color emojis.
Owner

For the SVG converter I think I mentioned elsewhere, but was it broken?
Did it actually need to be updated?
What problem did it solve?

For the SVG converter I think I mentioned elsewhere, but was it broken? Did it actually need to be updated? What problem did it solve?
Author
Contributor

It wasn't broken, it was simply missing support for many SVG features - maybe the logos it deals with don't use them, in which case it makes no difference.
But the change is like 10 lines of logic and makes sure we have improved SVG support. If you don't think that's worth it, you're free to not accept the change.

It wasn't broken, it was simply missing support for many SVG features - maybe the logos it deals with don't use them, in which case it makes no difference. But the change is like 10 lines of logic and makes sure we have improved SVG support. If you don't think that's worth it, you're free to not accept the change.
@ -42,3 +42,3 @@
data.insert::<Config>(Arc::new(RwLock::new(config)));
data.insert::<DataBase>(Arc::new(RwLock::new(db)));
data.insert::<DataBase>(Arc::new(db));
Owner

Out of curiosity did ye try and run the bot, or did ye entirely depend on fmt/clippy?

Asking as when first set up it needed to be using the rwlock, things might have changed since though.

Out of curiosity did ye try and run the bot, or did ye entirely depend on fmt/clippy? Asking as when first set up it needed to be using the rwlock, things might have changed since though.
Author
Contributor

The RwLock can't be required, as the only extra capability it adds is getting a mutable reference to the Database - something your code doesn't do once, and something sqlx's Pool intentionally avoids.

The RwLock can't be required, as the only extra capability it adds is getting a mutable reference to the Database - something your code doesn't do once, and something sqlx's Pool intentionally avoids.
Owner
- code doesn't do once
+ code doesn't do once now

Just be cause it is not now does not mean it never was.

Still set of comments was more remarking on it than actually needing it changed, so marking it resolved

```diff - code doesn't do once + code doesn't do once now ``` Just be cause it is not now does not mean it never was. Still set of comments was more remarking on it than actually needing it changed, so marking it resolved
silver marked this conversation as resolved
src/lib.rs Outdated
@ -109,3 +109,1 @@
if let Ok(x) = x.trim().parse::<u64>() {
config.committee_role = RoleId::new(x);
}
let x = x.trim().parse().unwrap();
Owner

Dont do this, its like saying that ye hate rust.

Dont do this, its like saying that ye hate rust.
Author
Contributor

The original code instead ignores errors - that is not better.
The error is invalid configuration, there is no reasonable way to recover from an error like this - the only reasonable course of action is to panic.

The original code instead ignores errors - that is not better. The error is invalid configuration, there is no reasonable way to recover from an error like this - the only reasonable course of action is to panic.
Owner

Please elaborate on how it is the only reasonable course of action is to panic

Please elaborate on how it is ``the only reasonable course of action is to panic``
Author
Contributor

This is an env flag set on deployment. It will only fail if you provide an invalid value for configuration.
So, the situation is: the discord bot has been started with improper configuration. What should we do?
Should we run and silently ignore invalid values, or should we alert whoever is responsible for the deployment?
Sure, you could say we can just print an error instead - but that is far less visible than the bot simply refusing to run if the configuration you provide doesn't make sense.

This is an env flag set on deployment. It will only fail if you provide an invalid value for configuration. So, the situation is: the discord bot has been started with improper configuration. What should we do? Should we run and silently ignore invalid values, or should we alert whoever is responsible for the deployment? Sure, you could say we can just print an error instead - but that is far less visible than the bot simply refusing to run if the configuration you provide doesn't make sense.
Owner

If we were running the bot for just ourselves then that logic would make sense.
However we provide it as a service to other clubs and societies, heck even that segment is for the committee server, which is not its core duty.
If it fails to parse the config values it will most likely remove teh committee role from committee members, which we will find out about pretty fast, but the normal users on the different discords would remain not impacted.

So not properly handling the error is not a valid choice ehre.

(Pretty impressed on how ye are picking up on the code as a whole)

If we were running the bot for just ourselves then that logic would make sense. However we provide it as a service to other clubs and societies, heck even that segment is for the committee server, which is not its core duty. If it fails to parse the config values it will most likely remove teh committee role from committee members, which we will find out about pretty fast, but the normal users on the different discords would remain not impacted. So not properly handling the error is not a valid choice ehre. (Pretty impressed on how ye are picking up on the code as a whole)
Author
Contributor

Alright, that seems reasonable. Thanks for the explanation.

Alright, that seems reasonable. Thanks for the explanation.
cordlesscoder marked this conversation as resolved
Author
Contributor

What leads you to say I'm writing code I don't understand? I made every change that has semantic significance with intent, and I can justify it just fine.

What leads you to say I'm writing code I don't understand? I made every change that has semantic significance with intent, and I can justify it just fine.
cordlesscoder added 2 commits 2025-09-11 09:35:05 +00:00
Use the longer format for some dependencies for compatibility with Taplo
Some checks failed
/ check_lfs (pull_request) Successful in 3s
/ lint_fmt (pull_request) Failing after 15s
/ lint_clippy (pull_request) Failing after 15s
/ build (pull_request) Has been skipped
0c7a61fbf2
Owner

Its not a big deal but maybe look into this for your typo commit, as it would make gitblame a little more useful. If someone in the future wanted to ask a follow up on a comment it would look like it was your comment instead of silver's.

Also check the ci/cd pipelines they seem to be failing

Its not a big deal but maybe look into [this](https://forgejo.org/docs/latest/user/blame/#ignore-commits-in-the-blame-view) for your typo commit, as it would make gitblame a little more useful. If someone in the future wanted to ask a follow up on a comment it would look like it was your comment instead of silver's. Also check the ci/cd pipelines they seem to be failing
cordlesscoder added 1 commit 2025-09-11 09:52:03 +00:00
Ignore fix typos commit for git blame
Some checks failed
/ check_lfs (pull_request) Successful in 3s
/ lint_fmt (pull_request) Failing after 16s
/ lint_clippy (pull_request) Failing after 15s
/ build (pull_request) Has been skipped
0cd0d745e2
Owner

@cordlesscoder wrote in #43 (comment):

What leads you to say I'm writing code I don't understand? I made every change that has semantic significance with intent, and I can justify it just fine.

#43 (comment)
Can ye say its a proper replacement?
How do ye know?
Why change somethign that is (literally) not broken?

@cordlesscoder wrote in https://forgejo.skynet.ie/Skynet/discord-bot/pulls/43#issuecomment-2430: > What leads you to say I'm writing code I don't understand? I made every change that has semantic significance with intent, and I can justify it just fine. https://forgejo.skynet.ie/Skynet/discord-bot/pulls/43#issuecomment-2419 Can ye say its a proper replacement? How do ye know? Why change somethign that is (literally) not broken?
Author
Contributor

@silver wrote in #43 (comment):

@cordlesscoder wrote in #43 (comment):

What leads you to say I'm writing code I don't understand? I made every change that has semantic significance with intent, and I can justify it just fine.

#43 (comment) Can ye say its a proper replacement? How do ye know? Why change somethign that is (literally) not broken?

FitTo was removed over 2 years ago. I can say that logically it's a proper replacement, but I have not tested it so I just asked to do that, as that's the change I think is most likely to be incorrect.

@silver wrote in https://forgejo.skynet.ie/Skynet/discord-bot/pulls/43#issuecomment-2441: > @cordlesscoder wrote in #43 (comment): > > > What leads you to say I'm writing code I don't understand? I made every change that has semantic significance with intent, and I can justify it just fine. > > #43 (comment) Can ye say its a proper replacement? How do ye know? Why change somethign that is (literally) not broken? FitTo was removed over 2 years ago. I can say that logically it's a proper replacement, but I have not tested it so I just asked to do that, as that's the change I think is most likely to be incorrect.
silver reviewed 2025-09-11 09:58:03 +00:00
@ -0,0 +1,2 @@
# Fix typos
4b4e5cb2894346684034cba93a5ac1ec6f884f9f
Owner

:3 I really like this (not too many folks know about this)

:3 I really like this (not too many folks know about this)
silver marked this conversation as resolved
silver reviewed 2025-09-11 09:58:43 +00:00
.rustfmt.toml Outdated
@ -7,4 +7,4 @@ fn_params_layout = "Compressed"
struct_lit_width = 0
tab_spaces = 2
use_small_heuristics = "Max"
imports_granularity = "Crate"
Owner

this diff may confuse folks in the future, but its fine

this diff may confuse folks in the future, but its fine
cordlesscoder added 1 commit 2025-09-11 10:10:54 +00:00
Add Taplo configuration
Some checks failed
/ check_lfs (pull_request) Successful in 2s
/ lint_fmt (pull_request) Failing after 14s
/ lint_clippy (pull_request) Failing after 15s
/ build (pull_request) Has been skipped
a6ce057030
cordlesscoder added 1 commit 2025-09-11 10:21:33 +00:00
Remove panics on invalid env arguments
Some checks failed
/ check_lfs (pull_request) Successful in 2s
/ lint_fmt (pull_request) Failing after 16s
/ lint_clippy (pull_request) Failing after 17s
/ build (pull_request) Has been skipped
a56b7cbd3f
silver reviewed 2025-09-11 10:54:56 +00:00
@ -30,2 +29,3 @@
# to make the http requests
[dependencies]
wolves_oxidised = { git = "https://forgejo.skynet.ie/Skynet/wolves-oxidised.git", features = ["unstable"] }
Owner

Fix it properly, that includes teh commented out one

Fix it properly, that includes teh commented out one
cordlesscoder marked this conversation as resolved
silver reviewed 2025-09-11 10:57:51 +00:00
@ -115,3 +115,1 @@
if let Ok(x) = part.trim().parse::<u64>() {
config.committee_category.push(ChannelId::new(x));
}
let Ok(x) = part.trim().parse() else { continue };
Owner

Fix it properly, this just changes it for teh sake of changing it

Fix it properly, this just changes it for teh sake of changing it
Author
Contributor

The logic is identical - in what way is this "improper", it's just less nested.

The logic is identical - in what way is this "improper", it's just less nested.
cordlesscoder added 1 commit 2025-09-11 10:59:05 +00:00
Restore Cargo.toml
Some checks failed
/ check_lfs (pull_request) Successful in 2s
/ lint_fmt (pull_request) Failing after 15s
/ lint_clippy (pull_request) Failing after 17s
/ build (pull_request) Has been skipped
e5a40261d9
cordlesscoder closed this pull request 2025-09-11 11:17:59 +00:00
Some checks failed
/ check_lfs (pull_request) Successful in 2s
/ lint_fmt (pull_request) Failing after 15s
/ lint_clippy (pull_request) Failing after 17s
/ build (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Skynet/discord-bot#43
No description provided.