From 198e3c62f4c9474a4cdc466f08b5c8d07464fc82 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 1 Sep 2024 12:30:25 -0400 Subject: [PATCH] ESM, man --- commands/random-img/xiao.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/random-img/xiao.js b/commands/random-img/xiao.js index cae2b9d7..63a341f4 100644 --- a/commands/random-img/xiao.js +++ b/commands/random-img/xiao.js @@ -1,9 +1,7 @@ const Command = require('../../framework/Command'); const { PermissionFlagsBits } = require('discord.js'); -const sagiri = require('sagiri'); const { embedURL } = require('../../util/Util'); const { SAUCENAO_KEY } = process.env; -const sagiriClient = sagiri(SAUCENAO_KEY); const fs = require('fs'); const path = require('path'); const images = fs.readdirSync(path.join(__dirname, '..', '..', 'assets', 'images', 'xiao')); @@ -33,6 +31,8 @@ module.exports = class XiaoCommand extends Command { }); this.cache = new Map(); + this.sagiri = null; + this.sagiriClient = null; } async run(msg) { @@ -72,7 +72,9 @@ module.exports = class XiaoCommand extends Command { return result; } - sauceNao(img) { + async sauceNao(img) { + if (!this.sagiri) this.sagiri = await import('sagiri'); + if (!this.sagiriClient) this.sagiriClient = this.sagiri(SAUCENAO_KEY); return sagiriClient(path.join(__dirname, '..', '..', 'assets', 'images', 'xiao', img)); } };