CustomId Codec
Reading time:1 min read
The CommandCustomIdCodec is responsible for de/serializing commands to/from customId strings, for the Command Components feature.
The default implementation (DefaultCommandCustomIdCodec) uses the @sapphire/string-store package to efficiently de/serialize the data.
When to override
| ✅ Override if you want to... | ❌ Don't override if you want to... |
|---|---|
| Use a custom de/serialization logic. | De/serialize your extra data. You should do that on sending/receiving instead, as it'll be easier to maintain. |
Overriding
Creation
Create a custom codec by either:
- Extending
DefaultCommandCustomIdCodec(@base's implementation, recommended for less work). - Implementing
CommandCustomIdCodec(@base's interface).
import { } from '@nyx-discord/djs';
class extends {}Registration
Create it and set it to the CommandManager.
import { } from '@nyx-discord/djs';
class extends {
/** Your overrides */
}
const = .();
.().();The DefaultCommandCustomIdCodec.create() method instantiates your custom codec, not the default one.
Edit on GitHub
Last updated on
