-2

As mentioned in the title, my variable "isModUp" is "declared but its value is never read"

client.on("message", (channel, tags, message, self) => {
    if(self) return;
    const badges = tags.badges || {};
    const isBroadcaster = badges.broadcaster;
    const isMod = badges.moderator;
    const isModUp = isMod || isBroadcaster
});

I have copied some code off GitHub and for some reason this issue has never happened to anyone else. I use this variable here:

if(message.isModUp ("!gta.on")){
    client.say(channelName, "!title [EN/PC] GTA V W/VIEWERS! | !sc to join | !discord | !youtube | !socials| !nerdordie| #RazerStreamer")
    client.say(channelName, "!game Grand Theft Auto V")
}

if(message.isModUp ("!warface.on")){
    client.say(channelName, "!title [EN/PC] Playing Warface by myself! | !discord | !youtube | !socials| !nerdordie| #RazerStreamer #AMA #Solo")
    client.say(channelName, "!game Warface")
}

How do I fix this?

  • You are not using the `isModUp` variable, exactly as the error says. Doing `message.isModUp` accesses the `isModUp` property of the `message` object - it doesn't reference the standalone variable `isModUp`. – CertainPerformance Dec 04 '20 at 05:36
  • how would i go about making isModUp useful. i am using this to make a twitch bot and i want to add mod only commands – NitchGaming Studios Dec 04 '20 at 06:08
  • i tried removing the line of code `isModUp = isMod || isBroadcaster` but now `isMod` and `isBroadcaster` both get "declared but vlaue is never read" – NitchGaming Studios Dec 04 '20 at 07:08
  • ***What*** is reporting *"declared but its value is never read"*? [Visual Studio Code](https://en.wikipedia.org/wiki/Visual_Studio_Code)? Some build system? Something else? On what platform (hardware, operating system, software (all, including versions and editions))? When does it happen? – Peter Mortensen Aug 22 '23 at 16:22
  • OK, the OP has [left the building](https://www.explainxkcd.com/wiki/index.php/979:_Wisdom_of_the_Ancients): *"Last seen more than 1 year ago"* – Peter Mortensen Aug 22 '23 at 16:23

1 Answers1

0

I'm assuming that nowhere else does the variable isModUp appear and that the message variable is not a set that has a function called isModUp because isModUp is not a function anyway. In that case, there is the variable isModUp is defined but the value is never used so it would be save space and computer processing power to just remove that line of code.

Timothy Chen
  • 431
  • 3
  • 8
  • i need to use the ismodup variable else idk how to make my message mod only and above – NitchGaming Studios Dec 04 '20 at 06:08
  • Well the problem is that the variable is declared in a function which means that it is not global and can't be used outside of a function, so if this is node.js, you would have to declare it outside using let or var instead of const, and then give it its value inside the function so that it is still global. – Timothy Chen Dec 04 '20 at 16:20