Improve message checking, enable central request handler

This commit is contained in:
Essem 2022-03-17 14:28:35 -05:00
parent f32e5d2ae5
commit 52e038c88e
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
5 changed files with 17 additions and 16 deletions

1
app.js
View file

@ -111,6 +111,7 @@ const Admiral = new Fleet({
requestTimeout: 30000
}
},
useCentralRequestHandler: true,
services: [
{ name: "prometheus", ServiceWorker: PrometheusWorker },
{ name: "image", ServiceWorker: ImageWorker }

View file

@ -112,7 +112,7 @@ class ImageCommand extends Command {
if (e === "No available servers") return "I can't seem to contact the image servers, they might be down or still trying to start up. Please wait a little bit.";
throw e;
} finally {
if (status && await this.client.getMessage(status.channel.id, status.id).catch(() => undefined)) await status.delete();
if (status && status.channel.messages.has(status.id)) await status.delete();
runningCommands.delete(this.message.author.id);
}

View file

@ -17,7 +17,7 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => {
waitMessage.edit(`🔊 ${member.mention} is the new voice channel host.`);
} else {
try {
if (waitMessage.channel.messages.get(waitMessage.id)) await waitMessage.delete();
if (waitMessage.channel.messages.has(waitMessage.id)) await waitMessage.delete();
} catch {
// no-op
}
@ -40,7 +40,7 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => {
awaitRejoin.on("end", async (rejoined) => {
if (rejoined) {
try {
if (waitMessage.channel.messages.get(waitMessage.id)) await waitMessage.delete();
if (waitMessage.channel.messages.has(waitMessage.id)) await waitMessage.delete();
} catch {
// no-op
}
@ -48,7 +48,7 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => {
const members = oldChannel.voiceMembers.filter((i) => i.id !== client.user.id && !i.bot);
if (members.length === 0) {
try {
if (waitMessage.channel.messages.get(waitMessage.id)) await waitMessage.delete();
if (waitMessage.channel.messages.has(waitMessage.id)) await waitMessage.delete();
} catch {
// no-op
}

View file

@ -121,7 +121,7 @@ export default async (client, message, pages, timeout = 120000) => {
dropdownCollector.on("interaction", async (response) => {
if (response.data.custom_id !== "seekDropdown") return;
try {
if (await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) await askMessage.delete();
if (askMessage.channel.messages.has(askMessage.id)) await askMessage.delete();
} catch {
// no-op
}
@ -133,7 +133,7 @@ export default async (client, message, pages, timeout = 120000) => {
dropdownCollector.once("end", async () => {
if (ended) return;
try {
if (await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) await askMessage.delete();
if (askMessage.channel.messages.has(askMessage.id)) await askMessage.delete();
} catch {
// no-op
}
@ -146,7 +146,7 @@ export default async (client, message, pages, timeout = 120000) => {
case "delete":
await interaction.deferUpdate();
interactionCollector.emit("end");
if (await client.getMessage(currentPage.channel.id, currentPage.id).catch(() => undefined)) await currentPage.delete();
if (currentPage.channel.messages.has(currentPage.id)) await currentPage.delete();
return;
default:
break;
@ -158,7 +158,7 @@ export default async (client, message, pages, timeout = 120000) => {
for (const index of components.components[0].components.keys()) {
components.components[0].components[index].disabled = true;
}
if (await client.getMessage(currentPage.channel.id, currentPage.id).catch(() => undefined)) {
if (currentPage.channel.messages.has(currentPage.id)) {
await currentPage.edit(components);
}
});

View file

@ -150,9 +150,9 @@ export async function nextSong(client, message, connection, track, info, music,
players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: host, voiceChannel: voiceChannel, originalChannel: message.channel, loop: loop, shuffle: shuffle, playMessage: playingMessage });
connection.once("error", async (error) => {
try {
if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
if (playingMessage.channel.messages.has(playingMessage.id)) await playingMessage.delete();
const playMessage = players.get(voiceChannel.guild.id).playMessage;
if (playMessage.channel.messages.get(playMessage.id)) await playMessage.delete();
if (playMessage.channel.messages.has(playMessage.id)) await playMessage.delete();
} catch {
// no-op
}
@ -196,8 +196,8 @@ export async function nextSong(client, message, connection, track, info, music,
const newTrack = await Rest.decode(connection.node, newQueue[0]);
nextSong(client, message, connection, newQueue[0], newTrack, music, voiceChannel, host, player.loop, player.shuffle, track);
try {
if (newQueue[0] !== track && playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
if (newQueue[0] !== track && player.playMessage.channel.messages.get(player.playMessage.id)) await player.playMessage.delete();
if (newQueue[0] !== track && playingMessage.channel.messages.has(playingMessage.id)) await playingMessage.delete();
if (newQueue[0] !== track && player.playMessage.channel.messages.has(player.playMessage.id)) await player.playMessage.delete();
} catch {
// no-op
}
@ -209,15 +209,15 @@ export async function nextSong(client, message, connection, track, info, music,
skipVotes.delete(voiceChannel.guild.id);
if (music) await client.createMessage(message.channel.id, "🔊 The current voice channel session has ended.");
try {
if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
if (player && player.playMessage.channel.messages.get(player.playMessage.id)) await player.playMessage.delete();
if (playingMessage.channel.messages.has(playingMessage.id)) await playingMessage.delete();
if (player && player.playMessage.channel.messages.has(player.playMessage.id)) await player.playMessage.delete();
} catch {
// no-op
}
} else {
try {
if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
if (player && player.playMessage.channel.messages.get(player.playMessage.id)) await player.playMessage.delete();
if (playingMessage.channel.messages.has(playingMessage.id)) await playingMessage.delete();
if (player && player.playMessage.channel.messages.has(player.playMessage.id)) await player.playMessage.delete();
} catch {
// no-op
}