Skip to content

Conversation

didinele
Copy link
Member

Got the idea from a random convo I saw, I'd say it's a valuable addition. Method name inspired from zod, we can change if anyone has a better idea

Copy link

vercel bot commented Sep 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
discord-js Ignored Ignored Preview Oct 1, 2025 6:39am
discord-js-guide Ignored Ignored Preview Oct 1, 2025 6:39am

Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 95.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.56%. Comparing base (0d76f11) to head (ff9b2ca).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/builders/src/mixins/Refineable.ts 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11124      +/-   ##
==========================================
+ Coverage   44.46%   44.56%   +0.10%     
==========================================
  Files         312      313       +1     
  Lines       17956    17995      +39     
  Branches     1790     1790              
==========================================
+ Hits         7984     8020      +36     
- Misses       9960     9963       +3     
  Partials       12       12              
Flag Coverage Δ
builders 80.34% <95.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

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

I'd say it's a valuable addition.

Maybe add a test case of a simple & useful scenario? That could be nice to see! Reason I ask is because the documentation given for refining doesn't seem to solve a problem?

@didinele
Copy link
Member Author

Maybe add a test case of a simple & useful scenario? That could be nice to see! Reason I ask is because the documentation given for refining doesn't seem to solve a problem?

Will do. But the idea is that when you have a large block of logic that does a lot of conditional work on a builder, it can feel a bit "disconnected" and other logic can sneak in the middle, you also can end up introducing a lot of variables.

With refine you can get rid of a lot of that:

<TextBasedChannel>.send({
  embeds: [new EmbedBuilder().refine(builder => { /* ... complex logic here */ });
});

@faceboy1392
Copy link

I'd say it's a valuable addition.

Maybe add a test case of a simple & useful scenario? That could be nice to see! Reason I ask is because the documentation given for refining doesn't seem to solve a problem?

I proposed this idea originally in that "random convo", (and I think I first saw the idea somewhere else). The main reason is I just otherwise find it pretty inconvenient when I'm working with a long chain of builder method calls.

In my experience, it's sometimes annoying to conditionally modify the builder with external if statements and all that, rather than being able to put everything in one long expression. Especially when dealing with components nested inside other components/objects, and typescript gets mad at me without a bunch of type guards. I just much prefer being able to throw a code block in the middle of it rather than dealing with a bunch of variables, which feels more cluttered

idk if I'm making sense. I made my own custom container builder and added this function and I like it, and I wish djs had it (and I'm annoyed javascript has no way to do this sort of thing natively).

@didinele didinele force-pushed the feat/builders-refine branch from bb1b9e4 to 7a9c6ee Compare October 1, 2025 06:39
* .setDescription('This is a description')
* .refine((b) => {
* const intermediateValue = computeSomething();
* b.setFooter(`Computed value: ${intermediateValue}`);
Copy link
Member

Choose a reason for hiding this comment

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

This is an object!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

5 participants