Can I stop a discord.js command from running if automod deletes it?


This Content is from Stack Overflow. Question asked by ElijahDoesMC

I am very new when it comes to this bot stuff, but I am modifying this command in discord.js v13.2.0 and want it to not register if another bot deletes it first.

I initially thought using a delay might stop it but that just stops it’s response for the set amount of time, what it needs to do is wait maybe half a second and then if the command still exists after that time it should continue with what the command is intended to do.

Alternativley I could use a feature that blocks any of the specific words from being used but that may be more complicated, I’m unsure.

Here is the code that I want to make these changes to:

const discord = require("discord.js");
const figlet = require("figlet");

module.exports = {
    name: "ascii",
    aliases: [],
    category: "fun",
    usage: "ascii <text>",
    description: "Returns provided text in ascii format.",
    run: async (client, message, args) => {
      if( != "1020591171094986782") return message.reply('you cannot use this command here!')
  .then(msg => {
    setTimeout(() => msg.delete(), 5000) //customisable time

   let text = args.join(" ");
   if(!text) {
return`Please provide text for the ascii conversion!`).then(msg => {
    setTimeout(() => msg.delete(), 5000) //customisable time
   let maxlen = 20
if(text.length > 20) {
return`Please put text that contains 20 characters or less!`).then(msg => {
    setTimeout(() => msg.delete(), 5000) //customisable time
figlet(text, function(err, data) {, {
code: 'AsciiArt' 



This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?