rename all eris references, remove node-fetch, fix missing functions
This commit is contained in:
		
							parent
							
								
									ed486b4cbb
								
							
						
					
					
						commit
						185c5d8774
					
				
					 9 changed files with 58 additions and 75 deletions
				
			
		
							
								
								
									
										35
									
								
								src/index.js
									
										
									
									
									
								
							
							
						
						
									
										35
									
								
								src/index.js
									
										
									
									
									
								
							| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
const Eris = require("eris");
 | 
					const {Client, Collection} = require("oceanic.js");
 | 
				
			||||||
const logger = require("./lib/logger.js");
 | 
					const logger = require("./lib/logger.js");
 | 
				
			||||||
const fs = require("fs");
 | 
					const fs = require("fs");
 | 
				
			||||||
const {resolve} = require("path");
 | 
					const {resolve} = require("path");
 | 
				
			||||||
| 
						 | 
					@ -10,13 +10,16 @@ const Command = require("./lib/command.js");
 | 
				
			||||||
const events = require("./lib/events.js");
 | 
					const events = require("./lib/events.js");
 | 
				
			||||||
const timer = require("./lib/timer.js");
 | 
					const timer = require("./lib/timer.js");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const bot = new Eris(config.token, {
 | 
					const bot = new Client({
 | 
				
			||||||
 | 
					  auth: config.token,
 | 
				
			||||||
  defaultImageFormat: "png",
 | 
					  defaultImageFormat: "png",
 | 
				
			||||||
  defaultImageSize: 1024,
 | 
					  defaultImageSize: 1024,
 | 
				
			||||||
  intents: Object.keys(Eris.Constants.Intents),
 | 
					  gateway: {
 | 
				
			||||||
 | 
					    intents: ["ALL"],
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const commands = new Eris.Collection();
 | 
					const commands = new Collection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const database = new sqlite3.Database(resolve(__dirname, "..", "database.db"));
 | 
					const database = new sqlite3.Database(resolve(__dirname, "..", "database.db"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,18 +55,6 @@ for (const file of fs.readdirSync(resolve(__dirname, "modules"))) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bot.on("messageCreate", async (msg) => {
 | 
					bot.on("messageCreate", async (msg) => {
 | 
				
			||||||
  // fix DMs cause of gateway v8 changes
 | 
					 | 
				
			||||||
  if (
 | 
					 | 
				
			||||||
    !(msg.channel instanceof Eris.Channel) &&
 | 
					 | 
				
			||||||
    msg.author.id != bot.user.id &&
 | 
					 | 
				
			||||||
    !msg.guildID
 | 
					 | 
				
			||||||
  ) {
 | 
					 | 
				
			||||||
    const newChannel = await bot.getDMChannel(msg.author.id);
 | 
					 | 
				
			||||||
    if (msg.channel.id == newChannel.id) msg.channel = newChannel;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (!(msg.channel instanceof Eris.Channel)) return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  await CommandDispatcher(msg);
 | 
					  await CommandDispatcher(msg);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
bot.on("messageUpdate", (msg) => {
 | 
					bot.on("messageUpdate", (msg) => {
 | 
				
			||||||
| 
						 | 
					@ -73,17 +64,17 @@ bot.on("messageUpdate", (msg) => {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bot.on("ready", async () => {
 | 
					bot.once("ready", async () => {
 | 
				
			||||||
  logger.info("hf:main", "Connected to Discord.");
 | 
					  logger.info("hf:main", "Connected to Discord.");
 | 
				
			||||||
  logger.info(
 | 
					  logger.info("hf:main", `Logged in as: ${bot.user.tag} (${bot.user.id})`);
 | 
				
			||||||
    "hf:main",
 | 
					 | 
				
			||||||
    `Logged in as: ${bot.user.username}#${bot.user.discriminator} (${bot.user.id})`
 | 
					 | 
				
			||||||
  );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const channel = await bot.getDMChannel(config.owner_id);
 | 
					  const channel = await bot.users.get(config.owner_id)?.createDM();
 | 
				
			||||||
  if (channel) {
 | 
					  if (channel) {
 | 
				
			||||||
    channel.createMessage("<:ms_tick:503341995348066313> Loaded HiddenPhox.");
 | 
					    channel.createMessage("<:ms_tick:503341995348066313> Loaded HiddenPhox.");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  bot.on("ready", () => {
 | 
				
			||||||
 | 
					    logger.info("hf:main", "Reconnected to Discord.");
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bot.on("error", (err) => {
 | 
					bot.on("error", (err) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,3 @@
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const mappings = {};
 | 
					const mappings = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function cacheList() {
 | 
					async function cacheList() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
const Eris = require("eris");
 | 
					const {Collection} = require("oceanic.js");
 | 
				
			||||||
const murmurhash = require("murmurhash").v3;
 | 
					const murmurhash = require("murmurhash").v3;
 | 
				
			||||||
const {tinycolor} = require("@ctrl/tinycolor");
 | 
					const {tinycolor} = require("@ctrl/tinycolor");
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
function pastelize(id) {
 | 
					function pastelize(id) {
 | 
				
			||||||
  const hue = murmurhash(id) % 360;
 | 
					  const hue = murmurhash(id) % 360;
 | 
				
			||||||
| 
						 | 
					@ -159,7 +158,7 @@ async function hastebin(body) {
 | 
				
			||||||
  return "<https://nekobin.com/" + res.result.key + ">";
 | 
					  return "<https://nekobin.com/" + res.result.key + ">";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
hf.selectionMessages = hf.selectionMessages || new Eris.Collection();
 | 
					hf.selectionMessages = hf.selectionMessages || new Collection();
 | 
				
			||||||
async function selectionMessage(
 | 
					async function selectionMessage(
 | 
				
			||||||
  msg,
 | 
					  msg,
 | 
				
			||||||
  heading,
 | 
					  heading,
 | 
				
			||||||
| 
						 | 
					@ -215,47 +214,45 @@ async function selectionMessage(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return await new Promise((resolve, reject) => {
 | 
					  return await new Promise((resolve, reject) => {
 | 
				
			||||||
    function listener(interaction) {
 | 
					    function listener(interaction) {
 | 
				
			||||||
      if (interaction instanceof Eris.ComponentInteraction) {
 | 
					      const user = interaction.member.user || interaction.user;
 | 
				
			||||||
        const user = interaction.member.user || interaction.user;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (
 | 
					      if (
 | 
				
			||||||
          user.id == msg.author.id &&
 | 
					        user.id == msg.author.id &&
 | 
				
			||||||
          interaction.channel.id == msg.channel.id &&
 | 
					        interaction.channel.id == msg.channel.id &&
 | 
				
			||||||
          interaction.message.components[0].components[0].custom_id == msg.id
 | 
					        interaction.message.components[0].components[0].custom_id == msg.id
 | 
				
			||||||
        ) {
 | 
					      ) {
 | 
				
			||||||
          if (interaction.data.custom_id == "cancel") {
 | 
					        if (interaction.data.custom_id == "cancel") {
 | 
				
			||||||
            hf.events.remove("interactionCreate", `selection.${msg.id}`);
 | 
					          hf.events.remove("interactionCreate", `selection.${msg.id}`);
 | 
				
			||||||
            clearTimeout(hf.selectionMessages.get(msg.id));
 | 
					          clearTimeout(hf.selectionMessages.get(msg.id));
 | 
				
			||||||
            hf.selectionMessages.remove(msg.id);
 | 
					          hf.selectionMessages.remove(msg.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            interaction.deferUpdate();
 | 
					          interaction.deferUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            displayMessage.delete();
 | 
					          displayMessage.delete();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            reject("Canceled");
 | 
					          reject("Canceled");
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          hf.events.remove("interactionCreate", `selection.${msg.id}`);
 | 
				
			||||||
 | 
					          clearTimeout(hf.selectionMessages.get(msg.id));
 | 
				
			||||||
 | 
					          hf.selectionMessages.remove(msg.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          interaction.deferUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          displayMessage.delete();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          let result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          if (maxItems > 1) {
 | 
				
			||||||
 | 
					            result = options
 | 
				
			||||||
 | 
					              .filter((opt) => interaction.data.values.includes(opt.key))
 | 
				
			||||||
 | 
					              .map((opt) => opt.key);
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            hf.events.remove("interactionCreate", `selection.${msg.id}`);
 | 
					            result = options.filter(
 | 
				
			||||||
            clearTimeout(hf.selectionMessages.get(msg.id));
 | 
					              (opt) => opt.key == interaction.data.values[0]
 | 
				
			||||||
            hf.selectionMessages.remove(msg.id);
 | 
					            )[0].value;
 | 
				
			||||||
 | 
					 | 
				
			||||||
            interaction.deferUpdate();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            displayMessage.delete();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            let result;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (maxItems > 1) {
 | 
					 | 
				
			||||||
              result = options
 | 
					 | 
				
			||||||
                .filter((opt) => interaction.data.values.includes(opt.key))
 | 
					 | 
				
			||||||
                .map((opt) => opt.key);
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
              result = options.filter(
 | 
					 | 
				
			||||||
                (opt) => opt.key == interaction.data.values[0]
 | 
					 | 
				
			||||||
              )[0].value;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            resolve(result);
 | 
					 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          resolve(result);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,5 @@
 | 
				
			||||||
const events = require("../lib/events.js");
 | 
					const events = require("../lib/events.js");
 | 
				
			||||||
const {hasFlag} = require("../lib/guildSettings.js");
 | 
					const {hasFlag} = require("../lib/guildSettings.js");
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const REGEX_GITHUB =
 | 
					const REGEX_GITHUB =
 | 
				
			||||||
  /(?:\s|^)https?:\/\/(www\.)?github\.com\/.+?\/.+?\/blob\/([a-zA-Z0-9-_.#/]*)/g;
 | 
					  /(?:\s|^)https?:\/\/(www\.)?github\.com\/.+?\/.+?\/blob\/([a-zA-Z0-9-_.#/]*)/g;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
const Command = require("../lib/command.js");
 | 
					const Command = require("../lib/command.js");
 | 
				
			||||||
const CATEGORY = "misc";
 | 
					const CATEGORY = "misc";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					 | 
				
			||||||
const {tinycolor} = require("@ctrl/tinycolor");
 | 
					const {tinycolor} = require("@ctrl/tinycolor");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const logger = require("../lib/logger.js");
 | 
					const logger = require("../lib/logger.js");
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
const Command = require("../lib/command.js");
 | 
					const Command = require("../lib/command.js");
 | 
				
			||||||
const CATEGORY = "misc";
 | 
					const CATEGORY = "misc";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					 | 
				
			||||||
const {
 | 
					const {
 | 
				
			||||||
  hastebin,
 | 
					  hastebin,
 | 
				
			||||||
  safeString,
 | 
					  safeString,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,5 @@
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					 | 
				
			||||||
const ytdl = require("ytdl-core");
 | 
					const ytdl = require("ytdl-core");
 | 
				
			||||||
const Eris = require("eris");
 | 
					const {Collection} = require("oceanic.js");
 | 
				
			||||||
const ffprobe = require("node-ffprobe");
 | 
					const ffprobe = require("node-ffprobe");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const Command = require("../lib/command.js");
 | 
					const Command = require("../lib/command.js");
 | 
				
			||||||
| 
						 | 
					@ -19,7 +18,7 @@ const REGEX_FILE =
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let SOUNDCLOUD_CLIENTID;
 | 
					let SOUNDCLOUD_CLIENTID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
hf.voiceStorage = hf.voiceStorage || new Eris.Collection();
 | 
					hf.voiceStorage = hf.voiceStorage || new Collection();
 | 
				
			||||||
const voiceStorage = hf.voiceStorage;
 | 
					const voiceStorage = hf.voiceStorage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// https://stackoverflow.com/a/12646864 § "Updating to ES6 / ECMAScript 2015"
 | 
					// https://stackoverflow.com/a/12646864 § "Updating to ES6 / ECMAScript 2015"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,6 @@ if (!fs.existsSync(resolve(__dirname, "..", "..", "private_reminders.json")))
 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const tzFormatterCache = {};
 | 
					const tzFormatterCache = {};
 | 
				
			||||||
const dmCache = {};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const reminderData = require(resolve(
 | 
					const reminderData = require(resolve(
 | 
				
			||||||
  __dirname,
 | 
					  __dirname,
 | 
				
			||||||
| 
						 | 
					@ -82,9 +81,7 @@ hf.bot.once("ready", () => {
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!dmCache[data.user]) {
 | 
					        const channel = await hf.bot.users.get(data.user)?.createDM();
 | 
				
			||||||
          dmCache[data.user] = await hf.bot.getDMChannel(data.user);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const [date, time] = tzFormatterCache[data.tz]
 | 
					        const [date, time] = tzFormatterCache[data.tz]
 | 
				
			||||||
          .format(Date.now())
 | 
					          .format(Date.now())
 | 
				
			||||||
| 
						 | 
					@ -94,8 +91,13 @@ hf.bot.once("ready", () => {
 | 
				
			||||||
        minutes = parseInt(minutes);
 | 
					        minutes = parseInt(minutes);
 | 
				
			||||||
        const lastRan = await getLastRun(data.user);
 | 
					        const lastRan = await getLastRun(data.user);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (date != lastRan && hour == data.hour && minutes == 0) {
 | 
					        if (
 | 
				
			||||||
          dmCache[data.user].createMessage(":alarm_clock: " + data.message);
 | 
					          date != lastRan &&
 | 
				
			||||||
 | 
					          hour == data.hour &&
 | 
				
			||||||
 | 
					          minutes == 0 &&
 | 
				
			||||||
 | 
					          channel != null
 | 
				
			||||||
 | 
					        ) {
 | 
				
			||||||
 | 
					          await channel.createMessage(":alarm_clock: " + data.message);
 | 
				
			||||||
          await setLastRun(data.user, date);
 | 
					          await setLastRun(data.user, date);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,7 +57,6 @@ EMOJI_SETS.fb = EMOJI_SETS.facebook;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const CUSTOM_EMOTE_REGEX = /<(?:\u200b|&)?(a)?:(\w+):(\d+)>/;
 | 
					const CUSTOM_EMOTE_REGEX = /<(?:\u200b|&)?(a)?:(\w+):(\d+)>/;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const fetch = require("node-fetch");
 | 
					 | 
				
			||||||
const sharp = require("sharp");
 | 
					const sharp = require("sharp");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const {hastebin, lookupUser} = require("../lib/utils.js");
 | 
					const {hastebin, lookupUser} = require("../lib/utils.js");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue