kyra
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
By the way, the docs are a bit oddly formatted but, you can check all the methods
Result
has here: https://sapphirejs.dev/docs/Documentation/api-utilities/@sapphire/result/classes/Result/#methods54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
And Sapphire args always throw an extension of
UserError
, so if you're not doing dynamic handling nor error message customization, you can do .pick
instead54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
And that'll send a translated message to the user using the guild's locale, using this code:
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
For example Skyra does this a lot:
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
And needless to say, Sapphire comes with error handlers so
UserError
is sent to the user54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
.unwrap()
will throw an error if there's no value tho54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
And then on the last lines you do
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
Same for
getText
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
All in all you can keep your code still, with minor changes
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
I really need to make
AsyncResult
and AsyncOption
😅54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
That being said, you made me realise I should add async variations of all the methods, so the following code becomes valid:
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
But like we support both handling your errors with
Result
, or with try-catch, it's your app, your code is up to you54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
The try-catch is precisely why we have
Result
, it's bulky otherwise.54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
I also understand a lot of people don't have written Rust code. It is after all a very powerful but very complicated to learn and use language. Which is why I focused so much on the documentation, so you can see the methods it has and what you can do with them, also predict the behaviour it will have once you execute it (which to be fair is hard without
Result
). There are patterns you can follow, for example those codeblocks are similar:
Or even with Option
:54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
I can understand the feeling, my main app, @Skyra, is ridden with legacy code that just repels me. When she was a multipurpose app back then, a single change, even technically non-breaking, was breaking Skyra. It felt like this comic all the time: https://xkcd.com/1172/
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
54 replies
SIASapphire - Imagine a framework
•Created by <RefCell<Mutex<Win>> on 11/9/2024 in #sapphire-support
weird behavior with args.*Result after updating to sapphire v5.3.1
If you wanna check the source code: https://github.com/sapphiredev/utilities/blob/main/packages/result/src/lib/Result.ts
54 replies