Only delete messages if they exist, removes errors in console
This commit is contained in:
parent
7047081f98
commit
6e8473d784
9 changed files with 14 additions and 14 deletions
|
@ -13,7 +13,7 @@ exports.run = async (message, args) => {
|
||||||
type: image.type.toUpperCase(),
|
type: image.type.toUpperCase(),
|
||||||
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
||||||
});
|
});
|
||||||
await processMessage.delete();
|
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
|
||||||
return {
|
return {
|
||||||
file: outputFinal,
|
file: outputFinal,
|
||||||
name: `caption.${image.type}`
|
name: `caption.${image.type}`
|
||||||
|
|
|
@ -13,7 +13,7 @@ exports.run = async (message, args) => {
|
||||||
type: image.type.toUpperCase(),
|
type: image.type.toUpperCase(),
|
||||||
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
||||||
});
|
});
|
||||||
await processMessage.delete();
|
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
|
||||||
return {
|
return {
|
||||||
file: outputFinal,
|
file: outputFinal,
|
||||||
name: `caption2.${image.type}`
|
name: `caption2.${image.type}`
|
||||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
||||||
type: image.type.toUpperCase(),
|
type: image.type.toUpperCase(),
|
||||||
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
||||||
});
|
});
|
||||||
await processMessage.delete();
|
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
|
||||||
return {
|
return {
|
||||||
file: buffer,
|
file: buffer,
|
||||||
name: "globe.gif"
|
name: "globe.gif"
|
||||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
||||||
type: image.type.toUpperCase(),
|
type: image.type.toUpperCase(),
|
||||||
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
||||||
});
|
});
|
||||||
await processMessage.delete();
|
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
|
||||||
return {
|
return {
|
||||||
file: buffer,
|
file: buffer,
|
||||||
name: `magik.${image.type}`
|
name: `magik.${image.type}`
|
||||||
|
|
|
@ -15,7 +15,7 @@ exports.run = async (message, args) => {
|
||||||
type: image.type.toUpperCase(),
|
type: image.type.toUpperCase(),
|
||||||
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
||||||
});
|
});
|
||||||
processMessage.delete();
|
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
|
||||||
return {
|
return {
|
||||||
file: buffer,
|
file: buffer,
|
||||||
name: `motivate.${image.type}`
|
name: `motivate.${image.type}`
|
||||||
|
|
|
@ -10,7 +10,7 @@ exports.run = async (message) => {
|
||||||
type: image.type.toUpperCase(),
|
type: image.type.toUpperCase(),
|
||||||
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
delay: image.delay ? (100 / image.delay.split("/")[0]) * image.delay.split("/")[1] : 0
|
||||||
});
|
});
|
||||||
await processMessage.delete();
|
if (processMessage.channel.messages.get(processMessage.id)) await processMessage.delete();
|
||||||
return {
|
return {
|
||||||
file: buffer,
|
file: buffer,
|
||||||
name: "spin.gif"
|
name: "spin.gif"
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports = async (member, oldChannel) => {
|
||||||
soundPlayer.players.set(connection.voiceChannel.guild.id, { player: connection.player, type: connection.type, host: member.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel });
|
soundPlayer.players.set(connection.voiceChannel.guild.id, { player: connection.player, type: connection.type, host: member.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel });
|
||||||
waitMessage.edit(`🔊 ${member.mention} is the new voice channel host.`);
|
waitMessage.edit(`🔊 ${member.mention} is the new voice channel host.`);
|
||||||
} else {
|
} else {
|
||||||
waitMessage.delete();
|
if (waitMessage.channel.messages.get(waitMessage.id)) waitMessage.delete();
|
||||||
connection.player.stop(connection.originalChannel.guild.id);
|
connection.player.stop(connection.originalChannel.guild.id);
|
||||||
soundPlayer.manager.leave(connection.originalChannel.guild.id);
|
soundPlayer.manager.leave(connection.originalChannel.guild.id);
|
||||||
connection.player.destroy();
|
connection.player.destroy();
|
||||||
|
@ -28,11 +28,11 @@ module.exports = async (member, oldChannel) => {
|
||||||
const awaitRejoin = new AwaitRejoin(oldChannel, false, member.id);
|
const awaitRejoin = new AwaitRejoin(oldChannel, false, member.id);
|
||||||
awaitRejoin.on("end", (rejoined) => {
|
awaitRejoin.on("end", (rejoined) => {
|
||||||
if (rejoined) {
|
if (rejoined) {
|
||||||
waitMessage.delete();
|
if (waitMessage.channel.messages.get(waitMessage.id)) waitMessage.delete();
|
||||||
} else {
|
} else {
|
||||||
const members = oldChannel.voiceMembers.filter((i) => i.id !== client.user.id);
|
const members = oldChannel.voiceMembers.filter((i) => i.id !== client.user.id);
|
||||||
if (members.length === 0) {
|
if (members.length === 0) {
|
||||||
waitMessage.delete();
|
if (waitMessage.channel.messages.get(waitMessage.id)) waitMessage.delete();
|
||||||
connection.player.stop(connection.originalChannel.guild.id);
|
connection.player.stop(connection.originalChannel.guild.id);
|
||||||
soundPlayer.manager.leave(connection.originalChannel.guild.id);
|
soundPlayer.manager.leave(connection.originalChannel.guild.id);
|
||||||
connection.player.destroy();
|
connection.player.destroy();
|
||||||
|
|
|
@ -27,7 +27,7 @@ module.exports = async (message, pages, timeout = 120000) => {
|
||||||
maxMatches: 1
|
maxMatches: 1
|
||||||
});
|
});
|
||||||
return messageCollector.on("message", response => {
|
return messageCollector.on("message", response => {
|
||||||
askMessage.delete();
|
if (askMessage.channel.messages.get(askMessage.id)) askMessage.delete();
|
||||||
page = Number(response.content) - 1;
|
page = Number(response.content) - 1;
|
||||||
currentPage.edit(pages[page]);
|
currentPage.edit(pages[page]);
|
||||||
if (manageMessages) msg.removeReaction("🔢", userID);
|
if (manageMessages) msg.removeReaction("🔢", userID);
|
||||||
|
@ -44,7 +44,7 @@ module.exports = async (message, pages, timeout = 120000) => {
|
||||||
case "🗑":
|
case "🗑":
|
||||||
deleted = true;
|
deleted = true;
|
||||||
reactionCollector.emit("end");
|
reactionCollector.emit("end");
|
||||||
currentPage.delete();
|
if (currentPage.channel.messages.get(currentPage.id)) currentPage.delete();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -103,7 +103,7 @@ exports.nextSong = async (message, connection, track, info, music, voiceChannel,
|
||||||
this.players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: message.author.id, voiceChannel: voiceChannel, originalChannel: message.channel });
|
this.players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: message.author.id, voiceChannel: voiceChannel, originalChannel: message.channel });
|
||||||
if (inQueue) {
|
if (inQueue) {
|
||||||
connection.on("error", (error) => {
|
connection.on("error", (error) => {
|
||||||
playingMessage.delete();
|
if (playingMessage.channel.messages.get(playingMessage.id)) playingMessage.delete();
|
||||||
this.manager.leave(voiceChannel.guild.id);
|
this.manager.leave(voiceChannel.guild.id);
|
||||||
connection.destroy();
|
connection.destroy();
|
||||||
this.players.delete(voiceChannel.guild.id);
|
this.players.delete(voiceChannel.guild.id);
|
||||||
|
@ -122,11 +122,11 @@ exports.nextSong = async (message, connection, track, info, music, voiceChannel,
|
||||||
this.players.delete(voiceChannel.guild.id);
|
this.players.delete(voiceChannel.guild.id);
|
||||||
this.queues.delete(voiceChannel.guild.id);
|
this.queues.delete(voiceChannel.guild.id);
|
||||||
if (music) await client.createMessage(message.channel.id, "🔊 The current voice channel session has ended.");
|
if (music) await client.createMessage(message.channel.id, "🔊 The current voice channel session has ended.");
|
||||||
await playingMessage.delete();
|
if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
|
||||||
} else {
|
} else {
|
||||||
const track = await fetch(`http://${connection.node.host}:${connection.node.port}/decodetrack?track=${encodeURIComponent(newQueue[0])}`, { headers: { Authorization: connection.node.password } }).then(res => res.json());
|
const track = await fetch(`http://${connection.node.host}:${connection.node.port}/decodetrack?track=${encodeURIComponent(newQueue[0])}`, { headers: { Authorization: connection.node.password } }).then(res => res.json());
|
||||||
this.nextSong(message, connection, newQueue[0], track, music, voiceChannel, true);
|
this.nextSong(message, connection, newQueue[0], track, music, voiceChannel, true);
|
||||||
await playingMessage.delete();
|
if (playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue