Added more activity messages, updated packages, allow any public Lavalink instance to be used via the "local" parameter, added clearer error message for API timeouts

This commit is contained in:
TheEssem 2021-01-04 10:29:18 -06:00
parent 9ab13f5389
commit dd114e27b5
7 changed files with 105 additions and 86 deletions

View file

@ -94,6 +94,7 @@ exports.getType = async (image) => {
}, 25000);
try {
const imageRequest = await fetch(image, { signal: controller.signal, highWaterMark: 512 });
clearTimeout(timeout);
const imageBuffer = await imageRequest.buffer();
const imageType = await fileType.fromBuffer(imageBuffer);
if (imageType && formats.includes(imageType.mime)) {
@ -119,7 +120,7 @@ exports.run = (object, fromAPI = false) => {
const data = Buffer.concat([Buffer.from([0x1]), Buffer.from(JSON.stringify(object))]);
const timeout = setTimeout(() => {
reject("Timed out");
reject("UDP timed out");
}, 25000);
let jobID;

View file

@ -55,6 +55,9 @@ exports.play = async (sound, message, music = false) => {
const player = this.players.get(message.channel.guild.id);
if (!music && this.manager.voiceStates.has(message.channel.guild.id) && (player && player.type === "music")) return `${message.author.mention}, I can't play a sound effect while playing music!`;
const node = this.manager.idealNodes[0];
if (!music && !nodes.filter(obj => obj.host === node.host)[0].local) {
sound = sound.replace(/\.\//, "https://raw.githubusercontent.com/esmBot/esmBot/master/");
}
const { tracks } = await fetch(`http://${node.host}:${node.port}/loadtracks?identifier=${sound}`, { headers: { Authorization: node.password } }).then(res => res.json());
const oldQueue = this.queues.get(voiceChannel.guild.id);
if (tracks.length === 0) return `${message.author.mention}, I couldn't find that song!`;