diff --git a/commands/anime/char.js b/commands/anime/char.js index b96be21..a3c5bf2 100644 --- a/commands/anime/char.js +++ b/commands/anime/char.js @@ -304,10 +304,11 @@ module.exports = { } else {return message.reply("Looks like you didn't find the character you were looking for.");} } else { - await message.channel.send({embeds: [asr.embed]}); - let conf = await ask(message, "Is this the character you meant?", 60000); + let preConfEmbed = await message.channel.send({embeds: [asr.embed]}); + let conf = await ask(message, "Is this the character you meant?", 60000, undefined, undefined, true); if (!['y', 'yes', 'ye', 'n', 'no'].includes(conf.trim().toLowerCase())) {clearDM(); return dmch.send("You must specify yes or no! Please try again.");} conf = ['y', 'yes', 'ye'].includes(conf.trim().toLowerCase()); + preConfEmbed.delete().catch(() => {}); if (!conf) {return message.channel.send("Well, I've got nothing, then. If that doesn't match the character you're looking for then I would try again with a more narrow search.");} fn = asr.id; } diff --git a/commands/anime/highvalue.js b/commands/anime/highvalue.js index 1548732..c6341c7 100644 --- a/commands/anime/highvalue.js +++ b/commands/anime/highvalue.js @@ -43,10 +43,11 @@ module.exports = { } else {return message.reply("Looks like you didn't find the character you were looking for.");} } else { - await message.channel.send({embeds: [asr.embed]}); - let conf = await ask(message, "Is this the character you meant?", 60000); + let preConfEmbed = await message.channel.send({embeds: [asr.embed]}); + let conf = await ask(message, "Is this the character you meant?", 60000, undefined, undefined, true); if (!['y', 'yes', 'ye', 'n', 'no'].includes(conf.trim().toLowerCase())) {clearDM(); return dmch.send("You must specify yes or no! Please try again.");} conf = ['y', 'yes', 'ye'].includes(conf.trim().toLowerCase()); + preConfEmbed.delete().catch(() => {}); if (!conf) {return message.channel.send("Well, I've got nothing, then. If that doesn't match the character you're looking for then I would try again with a more narrow search.");} fn = asr.id; } diff --git a/commands/anime/lovechar.js b/commands/anime/lovechar.js index 64a51a5..c598372 100644 --- a/commands/anime/lovechar.js +++ b/commands/anime/lovechar.js @@ -59,10 +59,11 @@ module.exports = { } else {return message.reply("Looks like you didn't find the character you were looking for.");} } else { - await message.channel.send({embeds: [asr.embed]}); - let conf = await ask(message, "Is this the character you meant?", 60000); + let preConfEmbed = await message.channel.send({embeds: [asr.embed]}); + let conf = await ask(message, "Is this the character you meant?", 60000, undefined, undefined, true); if (!['y', 'yes', 'ye', 'n', 'no'].includes(conf.trim().toLowerCase())) {clearDM(); return dmch.send("You must specify yes or no! Please try again.");} conf = ['y', 'yes', 'ye'].includes(conf.trim().toLowerCase()); + preConfEmbed.delete().catch(() => {}); if (!conf) {return message.channel.send("Well, I've got nothing, then. If that doesn't match the character you're looking for then I would try again with a more narrow search.");} fn = asr.id; } diff --git a/commands/anime/watched.js b/commands/anime/watched.js index dffe1a9..94f0221 100644 --- a/commands/anime/watched.js +++ b/commands/anime/watched.js @@ -71,10 +71,11 @@ module.exports = { } else {return message.reply("Looks like you didn't find the anime you were looking for.");} } else { - await message.channel.send({embeds: [asr.embed]}); - let conf = await ask(message, "Is this the anime you meant?", 60000); + let preConfEmbed = await message.channel.send({embeds: [asr.embed]}); + let conf = await ask(message, "Is this the anime you meant?", 60000, undefined, undefined, true); if (!['y', 'yes', 'ye', 'n', 'no'].includes(conf.trim().toLowerCase())) {clearDM(); return dmch.send("You must specify yes or no! Please try again.");} conf = ['y', 'yes', 'ye'].includes(conf.trim().toLowerCase()); + preConfEmbed.delete().catch(() => {}); if (!conf) {return message.channel.send("Well, I've got nothing, then. If that doesn't match the anime you're looking for then I would try again with a more narrow search.");} fn = asr.id;} let af = await AF.findOne({uid: message.author.id}) || new AF({uid: message.author.id}); diff --git a/commands/anime/watchlist.js b/commands/anime/watchlist.js index 9a91afa..9b0deab 100644 --- a/commands/anime/watchlist.js +++ b/commands/anime/watchlist.js @@ -77,10 +77,11 @@ module.exports = { } else {return message.reply("Looks like you didn't find the anime you were looking for.");} } else { - await message.channel.send({embeds: [asr.embed]}); - let conf = await ask(message, "Is this the anime you meant?", 60000); + let preConfEmbed = await message.channel.send({embeds: [asr.embed]}); + let conf = await ask(message, "Is this the anime you meant?", 60000, undefined, undefined, true); if (!['y', 'yes', 'ye', 'n', 'no'].includes(conf.trim().toLowerCase())) {clearDM(); return dmch.send("You must specify yes or no! Please try again.");} conf = ['y', 'yes', 'ye'].includes(conf.trim().toLowerCase()); + preConfEmbed.delete().catch(() => {}); if (!conf) {return message.channel.send("Well, I've got nothing, then. If that doesn't match the anime you're looking for then I would try again with a more narrow search.");} fn = asr.id;} let af = await AF.findOne({uid: message.author.id}) || new AF({uid: message.author.id}); @@ -122,7 +123,7 @@ module.exports = { else {return message.reply("Looks like you didn't find the anime you were looking for.");} } else { await message.channel.send({embeds: [asr.embed]}); - let conf = await ask(message, "Is this the anime you meant?", 60000); + let conf = await ask(message, "Is this the anime you meant?", 60000, undefined, undefined, true); if (!['y', 'yes', 'ye', 'n', 'no'].includes(conf.trim().toLowerCase())) {clearDM(); return dmch.send("You must specify yes or no! Please try again.");} conf = ['y', 'yes', 'ye'].includes(conf.trim().toLowerCase()); if (!conf) {return message.channel.send("Well, I've got nothing, then. If that doesn't match the anime you're looking for then I would try again with a more narrow search.");} diff --git a/util/ask.js b/util/ask.js index 52266bc..9487c6d 100644 --- a/util/ask.js +++ b/util/ask.js @@ -1,10 +1,15 @@ -module.exports = async (message, toAsk, time, nofilter, timeoutResponse) => { +module.exports = async (message, toAsk, time, nofilter, timeoutResponse, deleteAfter) => { let msg = await message.channel.send(toAsk); let filter = nofilter ? () => true : m => m.author.id === message.author.id; try { - let collected = await msg.channel.awaitMessages({filter: filter, max: 1, errors: ['time'], time: time}); - if (collected.first().attachments.size > 0) {collected = collected.first().attachments.first().url;} - else {collected = collected.first().content;} + let collectedO = await msg.channel.awaitMessages({filter: filter, max: 1, errors: ['time'], time: time}); + let collected; + if (collectedO.first().attachments.size > 0) {collected = collectedO.first().attachments.first().url;} + else {collected = collectedO.first().content;} + if (deleteAfter) { + msg.delete().catch(() => {}); + collectedO.first().delete().catch(() => {}); + } return collected; } catch { if (timeoutResponse) {message.reply("This question has timed out! Please try again.");}