-
-
Notifications
You must be signed in to change notification settings - Fork 21
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Summary
<Container> crashes at runtime when accentColor is not provided, even though ContainerProps documents accentColor as optional.
This causes command execution to fail for any Components v2 message using <Container> without an explicit color.
Affected Version
- commandkit:
1.2.0 - discord.js:
14.25.1 - Node.js:
v24.12.0 - OS:
Windows 11(NT 10.0.22631.0)
Minimal Reproduction
import { type ChatInputCommand, Container, TextDisplay } from 'commandkit';
export const command = {
name: 'repro',
description: 'Reproduce container accentColor crash',
};
export const chatInput: ChatInputCommand = async (ctx) => {
const container = (
<Container>
<TextDisplay content="Container without accentColor" />
</Container>
);
await ctx.interaction.reply({
components: [container],
flags: ['IsComponentsV2'],
});
};- Register and run
/repro. - Command fails with a runtime exception.
Actual Result
Command execution fails with:
TypeError [ColorConvert]: Unable to convert "undefined" to a number.
at resolveColor (.../node_modules/discord.js/src/util/Util.js:299:11)
at Container (.../node_modules/commandkit/src/components/display/container.ts:43:15)
...Expected Result
If accentColor is omitted, <Container> should render normally without throwing.
Why This Seems Like a Framework Bug
The docs/API indicate accentColor is optional (accentColor?: ColorResolvable).
From observed behavior and stack trace, container logic appears to call resolveColor even when accentColor is undefined.
Suspected conditional issue in container implementation:
- If code checks
typeof props.accentColor != null, that condition is always true becausetypeofreturns a string ("undefined","string", etc.), nevernull.
Suggested Fix
Guard directly on the value, not typeof:
if (props.accentColor != null) {
container.setAccentColor(resolveColor(props.accentColor));
}Workaround (for users)
Pass accentColor explicitly on every <Container> until fixed.
Documentation Reference
ContainerPropsAPI (accentColoroptional):- Container usage guide:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working