Suggestion Command For Your Discord Bot Using Discord.JS 1

Suggestion Command For Your Discord Bot Using Discord.JS

Suggestion Command For Your Discord Bot Using Discord.JS – Well, Suggestion command is very simple and easy to make command, you only need to take response from the author and send it to somewhere in your server. In my case i will take the response from the author and send it to suggestion channel, If you thinking about that how we can find suggestion channel from server then i shall tell you there is way of finding things from JSON response which is .find(). By using it you can find channel with name suggestion or suggestions, So lets get started.

const { MessageEmbed } = require("discord.js") //IMPORT MESSAGE EMBED


module.exports = {
  name: "suggest", //command namme
  usage: "suggest <message>", //how to use command?
  description: "Send your Suggestion", //Something about command
  category: "main", //Category of command
  run: (client, message, args) => {
    
    
  }
}

Now add if statement to check if author gave something to send or not!

const { MessageEmbed } = require("discord.js") //IMPORT MESSAGE EMBED


module.exports = {
  name: "suggest", //command namme
  usage: "suggest <message>", //how to use command?
  description: "Send your Suggestion", //Something about command
  category: "main", //Category of command
  run: (client, message, args) => {
    
     if(!args.length) {
      return message.channel.send("Please Give the Suggestion")
    }
    
    
  }
}

Well, Now we have to find the channel with name suggestion or suggestions and if it is not exist then return message to author.

const { MessageEmbed } = require("discord.js") //IMPORT MESSAGE EMBED


module.exports = {
  name: "suggest", //command namme
  usage: "suggest <message>", //how to use command?
  description: "Send your Suggestion", //Something about command
  category: "main", //Category of command
  run: (client, message, args) => {
    
     if(!args.length) {
      return message.channel.send("Please Give the Suggestion")
    }
     let channel = message.guild.channels.cache.find((x) => (x.name === "suggestion" || x.name === "suggestions"))
    
    
    if(!channel) {
      return message.channel.send("there is no channel with name - suggestions")
    }
                  
    
  }
}

After all of that stuff we gonna be defining embed and add reactions to message and send to suggestion channel that we just found. Make sure to add success message.

const { MessageEmbed } = require("discord.js")


module.exports = {
  name: "suggest",
  usage: "suggest <message>",
  description: "Send your Suggestion",
  category: "main",
  run: (client, message, args) => {
    
    if(!args.length) {
      return message.channel.send("Please Give the Suggestion")
    }
    
    let channel = message.guild.channels.cache.find((x) => (x.name === "suggestion" || x.name === "suggestions"))
    
    
    if(!channel) {
      return message.channel.send("there is no channel with name - suggestions")
    }
                                                    
    
    let embed = new MessageEmbed()
    .setAuthor("SUGGESTION: " + message.author.tag, message.author.avatarURL())
    .setThumbnail(message.author.avatarURL())
    .setColor("#ff2050")
    .setDescription(args.join(" "))
    .setTimestamp()
    
    
    channel.send(embed).then(m => {
      m.react("✅")
      m.react("❌")
    })
    

    
    message.channel.send("Sended Your Suggestion to " + channel)
    
  }
}

Table of Contents

VIDEO TUTORIAL

Leave a Reply

Your email address will not be published. Required fields are marked *