More Granular Raw Events
The client can now subscribe to more granular raw events.
For instance, instead of doing:
client.on("raw", (msg) => {
if (msg.command === "join") {
// ...
}
});
client.on("raw", (msg) => {
if (msg.command === "rpl_topic") {
// ...
}
});
it is now possible to just write:
client.on("raw:join", (msg) => {
// ...
});
client.on("raw:rpl_topic", (msg) => {
// ...
});
The previous raw
event name keeps the same behavior:
client.on("raw", (msg) => {
// all the raw events
});
But internally, it now translate into all the available raw events:
client.on([
"raw:admin", "raw:cap", "raw:connect", // ...
"raw:rpl_welcome", "raw:rpl_yourhost", "raw:rpl_created", // ...
"raw:err_unknownerror", "raw:err_nosuchnick", "raw:err_nosuchnick", // ...
], (msg) => {
// all the raw events
});
Multi Events Subscribing
Event emitter allow to listen more than one event.
Example from plugins/nicklist
:
client.on(["part", "kick", "quit", "kill"], (msg) => {
const { source, params } = msg; // msg is PartEvent | KickEvent | QuitEvent | KillEvent
const nick = "nick" in params ? params.nick : source?.name;
const channel = "channel" in params ? params.channel : undefined;
if (nick !== undefined) {
removeNick(nick, channel);
}
});
Allowing to listen to several events at a time can be handy in some specific cases.
Supported Server Feature Events
Events related to supported server features are now emitted:
isupport:chanmodes
andisupport:prefix
(used byplugins/chanmodes
to handle channel modes aspects)isupport:chantypes
(used byplugins/chantypes
to provide some helpers likeclient.utils.isChannel
)isupport:usermodes
They are mainly used to offer a way to be aware of the server features and allow client to update its own behavior.
Client Helpers
client.utils
contains some convenient methods based on supported server features.
Following have been added:
client.utils.isChannel
(previously imported fromcore/strings
)client.utils.isCtcp
(previously imported fromplugins/ctcp
)client.utils.createCtcp
(previously imported fromplugins/ctcp
)