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 fs = require("fs");
|
||||
const {resolve} = require("path");
|
||||
|
@ -10,13 +10,16 @@ const Command = require("./lib/command.js");
|
|||
const events = require("./lib/events.js");
|
||||
const timer = require("./lib/timer.js");
|
||||
|
||||
const bot = new Eris(config.token, {
|
||||
const bot = new Client({
|
||||
auth: config.token,
|
||||
defaultImageFormat: "png",
|
||||
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"));
|
||||
|
||||
|
@ -52,18 +55,6 @@ for (const file of fs.readdirSync(resolve(__dirname, "modules"))) {
|
|||
}
|
||||
|
||||
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);
|
||||
});
|
||||
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",
|
||||
`Logged in as: ${bot.user.username}#${bot.user.discriminator} (${bot.user.id})`
|
||||
);
|
||||
logger.info("hf:main", `Logged in as: ${bot.user.tag} (${bot.user.id})`);
|
||||
|
||||
const channel = await bot.getDMChannel(config.owner_id);
|
||||
const channel = await bot.users.get(config.owner_id)?.createDM();
|
||||
if (channel) {
|
||||
channel.createMessage("<:ms_tick:503341995348066313> Loaded HiddenPhox.");
|
||||
}
|
||||
bot.on("ready", () => {
|
||||
logger.info("hf:main", "Reconnected to Discord.");
|
||||
});
|
||||
});
|
||||
|
||||
bot.on("error", (err) => {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const fetch = require("node-fetch");
|
||||
|
||||
const mappings = {};
|
||||
|
||||
async function cacheList() {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const Eris = require("eris");
|
||||
const {Collection} = require("oceanic.js");
|
||||
const murmurhash = require("murmurhash").v3;
|
||||
const {tinycolor} = require("@ctrl/tinycolor");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
function pastelize(id) {
|
||||
const hue = murmurhash(id) % 360;
|
||||
|
@ -159,7 +158,7 @@ async function hastebin(body) {
|
|||
return "<https://nekobin.com/" + res.result.key + ">";
|
||||
}
|
||||
|
||||
hf.selectionMessages = hf.selectionMessages || new Eris.Collection();
|
||||
hf.selectionMessages = hf.selectionMessages || new Collection();
|
||||
async function selectionMessage(
|
||||
msg,
|
||||
heading,
|
||||
|
@ -215,7 +214,6 @@ async function selectionMessage(
|
|||
|
||||
return await new Promise((resolve, reject) => {
|
||||
function listener(interaction) {
|
||||
if (interaction instanceof Eris.ComponentInteraction) {
|
||||
const user = interaction.member.user || interaction.user;
|
||||
|
||||
if (
|
||||
|
@ -258,7 +256,6 @@ async function selectionMessage(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hf.events.add("interactionCreate", `selection.${msg.id}`, listener);
|
||||
hf.selectionMessages.set(
|
||||
msg.id,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const events = require("../lib/events.js");
|
||||
const {hasFlag} = require("../lib/guildSettings.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
const REGEX_GITHUB =
|
||||
/(?:\s|^)https?:\/\/(www\.)?github\.com\/.+?\/.+?\/blob\/([a-zA-Z0-9-_.#/]*)/g;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const Command = require("../lib/command.js");
|
||||
const CATEGORY = "misc";
|
||||
|
||||
const fetch = require("node-fetch");
|
||||
const {tinycolor} = require("@ctrl/tinycolor");
|
||||
|
||||
const logger = require("../lib/logger.js");
|
|
@ -1,7 +1,6 @@
|
|||
const Command = require("../lib/command.js");
|
||||
const CATEGORY = "misc";
|
||||
|
||||
const fetch = require("node-fetch");
|
||||
const {
|
||||
hastebin,
|
||||
safeString,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const fetch = require("node-fetch");
|
||||
const ytdl = require("ytdl-core");
|
||||
const Eris = require("eris");
|
||||
const {Collection} = require("oceanic.js");
|
||||
const ffprobe = require("node-ffprobe");
|
||||
|
||||
const Command = require("../lib/command.js");
|
||||
|
@ -19,7 +18,7 @@ const REGEX_FILE =
|
|||
|
||||
let SOUNDCLOUD_CLIENTID;
|
||||
|
||||
hf.voiceStorage = hf.voiceStorage || new Eris.Collection();
|
||||
hf.voiceStorage = hf.voiceStorage || new Collection();
|
||||
const voiceStorage = hf.voiceStorage;
|
||||
|
||||
// https://stackoverflow.com/a/12646864 § "Updating to ES6 / ECMAScript 2015"
|
||||
|
|
|
@ -18,7 +18,6 @@ if (!fs.existsSync(resolve(__dirname, "..", "..", "private_reminders.json")))
|
|||
return;
|
||||
|
||||
const tzFormatterCache = {};
|
||||
const dmCache = {};
|
||||
|
||||
const reminderData = require(resolve(
|
||||
__dirname,
|
||||
|
@ -82,9 +81,7 @@ hf.bot.once("ready", () => {
|
|||
});
|
||||
}
|
||||
|
||||
if (!dmCache[data.user]) {
|
||||
dmCache[data.user] = await hf.bot.getDMChannel(data.user);
|
||||
}
|
||||
const channel = await hf.bot.users.get(data.user)?.createDM();
|
||||
|
||||
const [date, time] = tzFormatterCache[data.tz]
|
||||
.format(Date.now())
|
||||
|
@ -94,8 +91,13 @@ hf.bot.once("ready", () => {
|
|||
minutes = parseInt(minutes);
|
||||
const lastRan = await getLastRun(data.user);
|
||||
|
||||
if (date != lastRan && hour == data.hour && minutes == 0) {
|
||||
dmCache[data.user].createMessage(":alarm_clock: " + data.message);
|
||||
if (
|
||||
date != lastRan &&
|
||||
hour == data.hour &&
|
||||
minutes == 0 &&
|
||||
channel != null
|
||||
) {
|
||||
await channel.createMessage(":alarm_clock: " + data.message);
|
||||
await setLastRun(data.user, date);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ EMOJI_SETS.fb = EMOJI_SETS.facebook;
|
|||
|
||||
const CUSTOM_EMOTE_REGEX = /<(?:\u200b|&)?(a)?:(\w+):(\d+)>/;
|
||||
|
||||
const fetch = require("node-fetch");
|
||||
const sharp = require("sharp");
|
||||
|
||||
const {hastebin, lookupUser} = require("../lib/utils.js");
|
||||
|
|
Loading…
Reference in a new issue