diff --git a/src/index.js b/src/index.js index f0e15c0..5ce3159 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,7 @@ bot.once("ready", async () => { logger.info("hf:main", "Connected to Discord."); logger.info("hf:main", `Logged in as: ${bot.user.tag} (${bot.user.id})`); - const channel = await bot.users.get(config.owner_id)?.createDM(); + const channel = await bot.getDMChannel(config.owner_id); if (channel) { channel.createMessage({ content: "<:ms_tick:503341995348066313> Loaded HiddenPhox.", diff --git a/src/modules/privateReminders.js b/src/modules/privateReminders.js index 58ec0b7..5ed6313 100644 --- a/src/modules/privateReminders.js +++ b/src/modules/privateReminders.js @@ -20,6 +20,7 @@ if (!fs.existsSync(resolve(__dirname, "..", "..", "private_reminders.json"))) return; const tzFormatterCache = {}; +const dmCache = {}; const reminderData = require(resolve( __dirname, @@ -83,7 +84,10 @@ hf.bot.once("ready", () => { }); } - const channel = await hf.bot.users.get(data.user)?.createDM(); + if (!dmCache[data.user]) { + dmCache[data.user] = await hf.bot.getDMChannel(data.user); + } + const channel = dmCache[data.user]; const [date, time] = tzFormatterCache[data.tz] .format(Date.now()) @@ -103,9 +107,6 @@ hf.bot.once("ready", () => { content: ":alarm_clock: " + data.message, }); await setLastRun(data.user, date); - logger.verbose("privateReminders", "successfully sent"); - } else { - logger.verbose("privateReminders", "dm channel is null"); } } }