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"Couldn't find user!");

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

let reportEmbed = new Discord.RichEmbed()



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

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


.addField("Time", message.createdAt)

.addField("Reason", rreason);

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

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





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:

Hope this helps!


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