feat: refineable

This commit is contained in:
didinele
2025-09-30 16:55:37 +03:00
parent 1c5674d9b2
commit a1c4501464

View File

@@ -0,0 +1,26 @@
/**
* Mixin used to provide {@link Refineable.refine}
*/
export class Refineable {
/**
* Refines this builder by applying the provided function to itself.
* Useful for conditionally modifying the builder without breaking the method chain, while also isolating
* the scope of temporary variables.
*
* @example
* ```ts
* const builder = new EmbedBuilder()
* .setTitle('Hello World')
* .setDescription('This is a description')
* .refine((b) => {
* if (externalVariable) {
* b.setColor('Red');
* }
* });
* ```
*/
public refine(fn: (builder: this) => void): this {
fn(this);
return this;
}
}