💬 Session CustomId Codec
The SessionCustomIdCodec
is the object responsible for encoding and decoding sessions custom ids. That is, custom ids
that refer to sessions. With this object you can easily create components that will update sessions when
they are used. It's stored by a SessionManager
, and you can get it via SessionManager#getCustomIdCodec()
.
👷 Creation
You can create a session custom ID codec by either:
- Extending
DefaultSessionCustomIdCodec
from@framework
(recommended). - Implementing the
SessionCustomIdCodec
interface from@core
.
- Extending DefaultSessionCustomIdCodec
- Implementing SessionCustomIdCodec
import { DefaultSessionCustomIdCodec } from '@nyx-discord/framework';
class MySessionCustomIdCodec extends DefaultSessionCustomIdCodec {
// ...
}
const myCodec = new MySessionCustomIdCodec();
const myBot = Bot.create((bot) => ({
sessions: DefaultSessionManager.create(bot, { customIdCodec: myCodec }),
}));
import { SessionCustomIdCodec } from '@nyx-discord/core';
class MySessionCustomIdCodec implements SessionCustomIdCodec {
// ...
}
const myCodec = new MySessionCustomIdCodec();
const myBot = Bot.create((bot) => ({
sessions: DefaultSessionManager.create(bot, { customIdCodec: myCodec }),
}));