partial thread event support

This commit is contained in:
Cynthia Foxwell 2021-11-09 10:56:10 -07:00
parent 2ec57a2b11
commit 2205245353
1 changed files with 16 additions and 0 deletions

View File

@ -118,6 +118,22 @@ bot.once("ready", async function () {
await cacheThreads(guilds.next().value);
});
bot.on("unknown", (packet) => {
if (packet.t == "THREAD_CREATE") {
const guild = bot.guilds.get(packet.d.guild_id);
if (!guild) {
logger.warn(
`Got THREAD_CREATE from invalid guild??? id: ${packet.d.guild_id}`
);
} else {
guild.channels.set(packet.d.id, new Eris.TextChannel(packet.d, bot));
}
} else if (packet.t == "THREAD_DELETE") {
const guild = bot.guilds.get(packet.d.guild_id);
guild.channels.delete(packet.d.id);
}
});
bot.on("error", (err) => {
logger.error("hf:main", "Catching error: " + err);
});