Closed ralyodio closed 2 years ago
Hi,
It will be available in the next release.
In the meantime you can do something like:
const client = new Client({ ... });
await client.connect( ... );
interface ChannelItem {
channel: string; // name of the channel
count: number; // total users count
topic: string; // topic description (if set)
}
const allChannelList: ChannelItem[] = [];
client.on("raw", (msg) => {
switch (msg.command) {
case "RPL_LIST": {
const [, channel, count, topic = ""] = msg.params;
const channelListItem = { channel, count: Number(count), topic };
allChannelList.push(channelListItem);
break;
}
case "RPL_LISTEND": {
console.log(allChannelList); // ALL the channel list
break;
}
}
});
// gets the channel list once connected and ready
client.on("register", (msg) => {
client.send("LIST");
});
Hi @ralyodio,
New version has been released.
You can now list all channels:
client.on("register", () => {
client.list();
});
and get the result:
client.on("list_reply", (msg) => {
for (const { channel, count, topic } of msg.channels) {
// ...
}
});
Due to a recent little breaking change in v0.7.0, it should now be:
client.on("list_reply", (msg) => {
const { name, count, topic } = msg.params.channels;
});
See also:
I'm looking to join a network and list all channels.