Cmd is not defined

if(cmd === ${prefix}report){

    //!report @ned this is the reason

let rUser = message.guild.member(message.mentions.user.first()) // message.guild.members.get(args[0]));

if(!rUser) return message.channel.send("Couldn't find user!");

let rreason = args.join(" ").slice(22);

let reportEmbed = new Discord.RichEmbed()

.setDescription("Reports")

.setColor("#15f153")

.addField("Reported User", `${rUser} with ID: ${rUser.id}`)

.addField("Reported By", `${message.author} with ID: ${message.author.id}`)

.addField("Channel", message.channel)

.addField("Time", message.createdAt)

.addField("Reason", rreason);

let reportschannel = message.guild.channels.find(`name`, "reports");

if(!reportschannel) return message.channel.send("couldn't find reports channel.");

message.delete().catch(O_o=>{});

reportschannel.send(reportEmbed);

return;

};

Error Code:
ReferenceError: cmd is not defined
at Object. (C:\Users\Admin\Desktop\Discord Bot\index.js:144:1)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11

How do I define the cmd. please help me fix this. ty :slight_smile:

Hey @ZentrixYT!

You see the error is self-explanatory - cmd is not declared and used without declaration.
You must first declare a variable in order to utilize it throughout the code.
Read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined

Hope this helps!

Hey!

It looks you’re trying to create a Discord bot lol

I think you should add these line of codes to define cmd

const args = message.content.trim().split(/ +/g); const cmd = args.shift().toLowerCase();

Big lol