Don't rely on lavacord eris helper package, another pagination fix attempt, make cowsay use a different lib

This commit is contained in:
TheEssem 2021-03-05 12:06:22 -06:00
parent 45bb53d521
commit 2499fb2a3b
7 changed files with 4705 additions and 671 deletions

View file

@ -1,65 +1,16 @@
const cowsay = require("cowsay");
const cowList = ["beavis.zen",
"bong",
"bud-frogs",
"bunny",
"cheese",
"cower",
"daemon",
"default",
"doge",
"dragon-and-cow",
"dragon",
"elephant-in-snake",
"elephant",
"eyes",
"flaming-sheep",
"ghostbusters",
"goat",
"hedgehog",
"hellokitty",
"kiss",
"kitty",
"koala",
"kosh",
"luke-koala",
"mech-and-cow",
"meow",
"milk",
"moofasa",
"moose",
"mutilated",
"ren",
"satanic",
"sheep",
"skeleton",
"small",
"squirrel",
"stegosaurus",
"stimpy",
"supermilker",
"surgery",
"telebears",
"turkey",
"turtle",
"tux",
"vader-koala",
"vader",
"whale",
"www"
];
const cowsay = require("cowsay2");
const cows = require("cowsay2/cows");
exports.run = async (message, args) => {
if (args.length === 0) {
return `${message.author.mention}, you need to provide some text for the cow to say!`;
} else if (cowList.includes(args[0].toLowerCase())) {
const cow = args.shift().toLowerCase();
return `\`\`\`\n${cowsay.say({
text: args.join(" "),
f: cow
} else if (cows[args[0].toLowerCase()] != undefined) {
const cow = cows[args.shift().toLowerCase()];
return `\`\`\`\n${cowsay.say(args.join(" "), {
cow
})}\n\`\`\``;
} else {
return `\`\`\`\n${cowsay.say({ text: args.join(" ") })}\n\`\`\``;
return `\`\`\`\n${cowsay.say(args.join(" "))}\n\`\`\``;
}
};

16
events/rawWS.js Normal file
View file

@ -0,0 +1,16 @@
const player = require("../utils/soundplayer.js");
// run when a raw packet is sent, used for sending data to lavalink
module.exports = async (packet) => {
switch (packet.t) {
case "VOICE_SERVER_UPDATE":
await player.manager.voiceServerUpdate(packet.d);
break;
case "VOICE_STATE_UPDATE":
await player.manager.voiceStateUpdate(packet.d);
break;
case "GUILD_CREATE":
for (const state of packet.d.voice_states) await player.manager.voiceStateUpdate({ ...state, guild_id: packet.d.id });
break;
}
};

5267
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -22,13 +22,12 @@
"url": "git+https://github.com/esmBot/esmBot.git"
},
"dependencies": {
"@lavacord/eris": "0.0.3",
"abort-controller": "^3.0.0",
"cowsay": "^1.4.0",
"cowsay2": "^2.0.4",
"dblapi.js": "^2.4.1",
"dotenv": "^8.2.0",
"duckduckgo-images-api": "github:benpbolton/duckduckgo-images-api",
"emoji-regex": "^8.0.0",
"duckduckgo-images-api": "^1.0.5",
"emoji-regex": "^9.2.2",
"eris": "^0.14.0",
"file-type": "^16.1.0",
"jsqr": "^1.3.1",

View file

@ -28,7 +28,7 @@ Default prefix is \`&\`.
general: ["## 💻 General"],
tags: ["## 🏷️ Tags"],
fun: ["## 👌 Fun"],
images: ["## 🖼️ Image Editing", "> These commands support the PNG, JPEG, WEBP, and GIF formats. (GIF support is currently experimental)\n"],
images: ["## 🖼️ Image Editing", "> These commands support the PNG, JPEG, WEBP, and GIF formats.\n"],
soundboard: ["## 🔊 Soundboard"],
music: ["## 🎤 Music"]
};

View file

@ -50,8 +50,13 @@ module.exports = async (message, pages, timeout = 120000) => {
}
});
reactionCollector.once("end", async () => {
if (currentPage.channel.messages.get(currentPage.id) && manageMessages) {
await currentPage.removeReactions();
try {
await currentPage.channel.getMessage(currentPage.id);
if (manageMessages) {
await currentPage.removeReactions();
}
} catch {
return;
}
});
return currentPage;

View file

@ -4,7 +4,7 @@ const paginator = require("./pagination/pagination.js");
const fetch = require("node-fetch");
const moment = require("moment");
require("moment-duration-format");
const { Manager } = require("@lavacord/eris");
const { Manager } = require("lavacord");
let nodes = require("../servers.json").lava;
@ -35,8 +35,14 @@ exports.checkStatus = async () => {
};
exports.connect = async () => {
this.manager = new Manager(client, nodes, {
user: client.user.id
this.manager = new Manager(nodes, {
user: client.user.id,
shards: client.shards.size || 1,
send: (packet) => {
const guild = client.guilds.get(packet.d.guild_id);
if (!guild) return;
return guild.shard.sendWS(packet.op, packet.d);
}
});
const { length } = await this.manager.connect();
logger.log(`Successfully connected to ${length} Lavalink node(s).`);