This command is only available to moderators

Hi, I am having issues with my custom twitch bot with mIRC, I have a points system set up but whenever I try to do anything it returns “This command is only available to moderators” Even though I am a moderator

Here is my code

alias -l addPoints {
if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
var %topic $+($chan,.,$nick)
var %points $calc($readini(Points.ini,%topic,Points) + $1)
writeini -n Points.ini %topic Points %points
return %points
}

alias -l lookUpPoints {
var %topic $+($chan,.,$nick)
var %points $readini(Points.ini,%topic,Points)
return %points
}
alias doaddpoints {
if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
var %topic $+($1,.,$2)
var %points $calc($readini(Points.ini,%topic,Points) + $3)
writeini -n Points.ini %topic Points %points
echo -a Added points for %topic
}

alias dorempoints {
var %topic $+($1,.,$2)
remini -n Points.ini %topic Points
echo -a Removed points for %topic
}

on !:join:#:{
$+(.timerpoints.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
add.pts $+(#,.,$nick)
}
on !
:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts { writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1) }

ON !:TEXT:!:#: {
tokenize 32 $strip($1-,burci)
if ($1 == !points) {
if (!$2) {
if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
set -u10 %floodpoints On
set -u30 %floodpoints. $+ $nick On
msg # $nick has $iif($readini(Points.ini,$+(#,.,$nick),Points),$v1,0) total points.
}
elseif ($2) {
if ($nick isop #) {
if ($0 < 3) { msg # Insufficient parameters: Use !points <add|remove> [number] | return }
writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
msg $chan $3 now has $iif($readini(Points.ini,$+(#,.,$3),Points),$v1,0) total points.
}
else { msg $chan This command is only available to moderators. }
}
}
}

Since you are using isop on mIRC, mIRC will have to see the nick list and that you are an Operator.

Right after connected, but before joining any channels, run:

/raw CAP REQ :twitch.tv/membership

This will make the nicklist with operator status appear, but I think you will find it to be buggy, the list won’t function sometimes. This is because mIRC is trying to update it by running /name which doesn’t work the way it does on an normal IRC setup.

You could run:
/raw CAP REQ :twitch.tv/tags

…but then you won’t be using isop, you will have to check the tags on each username as they do the command. It’s not impossible and fairly easy if you know what you are doing. If you are a novice I forsee some stress in your future.

Some people have been known to query /mods to check for a moderator. You will want to do securely to prevent any abuse (not just an “isin” check because if my name is matt_thomas and someone realizes what you are doing, someone could join as att_thoma and use all the commands because it “isin” the results. :stuck_out_tongue_winking_eye: )

I have even thought about querying the undocumented TMI API, but since it’s not documented and supported, it can change at anytime without any notice.

-As Fugiman would never say “…don’t use mIRC…”

If you are testing said bot in YOUR channel. You are the BROADCASTER, a BROADCASTER is technically not a MODERATOR.

This is worth taking into consideration…

As @matt_thomas has said, checking OP status requires the membership CAP

Okay, Thanks guys! That helped a lot! :smile:

Luckily the most recent version mIRC has support for IRCv3 tags, so it’s fairly easy to check for moderator that way. I made a simple script to make that easier: http://pastebin.com/9tBbbCCw

With that script loaded, you can then use the defined indentifiers in your script.

Instead of:

if ($nick isop #) {
  ;do something
}

You would write:

if ($hasModPowers) {
  ;do something
}

The $hasModPowers identifier includes all kinds of moderation powers, so regular mods, the broadcaster, global mods, admins and staff. There are also other identifiers included.

Note that this only works in the on text event for a message that contains the correct tags, it doesn’t keep track of mod status otherwise (this is also why no nick or channel is required, it checks the $msgtags attached to the message). But for reacting to commands it is enough and more reliable than anything else at the moment.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.