diff --git a/src/index.js b/src/index.js index fa9aa36..06c2f48 100644 --- a/src/index.js +++ b/src/index.js @@ -1,13 +1,3 @@ -// ensure gateway/rest v9 -const Constants = require("eris/lib/Constants"); - -const fixedConstants = Constants; -fixedConstants.GATEWAY_VERSION = 9; -fixedConstants.REST_VERSION = 9; - -const constantsPath = require.resolve("eris/lib/Constants"); -require.cache[constantsPath].exports = fixedConstants; - const Eris = require("eris"); const logger = require("./lib/logger.js"); const fs = require("fs"); @@ -72,12 +62,8 @@ bot.on("messageCreate", async (msg) => { ) { const newChannel = await bot.getDMChannel(msg.author.id); if (msg.channel.id == newChannel.id) msg.channel = newChannel; - } else if (msg.guildID && !(msg.channel instanceof Eris.Channel)) { - const newChannel = bot.guilds.get(msg.guildID).channels.get(msg.channel.id); - if (newChannel) msg.channel = newChannel; } - // if we still have no dm channel (threads cause this too) if (!(msg.channel instanceof Eris.Channel)) return; await CommandDispatcher(msg); @@ -102,38 +88,6 @@ bot.on("ready", async () => { } }); -bot.once("ready", async function () { - const guilds = bot.guilds.values(); - async function cacheThreads(guild) { - if (!guild) return; - const threads = await bot.requestHandler - .request("GET", `/guilds/${guild.id}/threads/active`, true) - .then((x) => x.threads); - for (const thread of threads) { - guild.channels.set(thread.id, new Eris.TextChannel(thread, bot)); - } - const next = guilds.next().value; - if (next) await cacheThreads(next); - } - 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); });