mIRC Homepage
HI so I recently trying to figure out a command on my Twitch bot to !addcommand and !delete Command and The !addcom works just fine but the delete is not... I also want to figure out how to edit a Command as well if anyone can help me out that would be great

Code:
on*:text:!addcommand *:#: { 
write commands.txt $2-
}
on*:text:*:#: {
if ($read(commands.txt, ns, $1)) {
 msg $chan $v1
}
}
on *:text:!delcom *:#: {
if ($read(commands.txt, ns, $2)) {
 write -dl $+ $readn commands.txt
}
}
Move the !delcom code above the * code. Same goes for any other text events you add.
The event catching "*" matches "!delcom" also because * matches everything. Only one matching event from each file can trigger, so if something else matches it first it will never trigger.

Editing a line is as simple as replacing it, use $readn the same as your delcom except without the d switch. Again remember to place it above the "*" event.
Code:
on *:text:!editcom & *:#: {
  if ($read(commands.txt, ns, $2)) {
    write -l $+ $readn commands.txt $2-
  }
}

omg you are awesome thanks so much works like a charm!

and Also one more thing I wonder if there a way when you type in !commands it shows all the commands you have on the list... like for a list for people know what commands you have
you need to use a if statement if the commands should be listed.
Code:
on *:text:!addcommand *:#: { 
 if ($2 == show) { msg $chan Commands avalible are <enter commands here> | return }
  else {
  write commands.txt $2-
 }
}


So I did the code. Do i have to enter the commands manually? I wonder if it would just read the list of Commands I already have ...
It might be easier to just /play the file smile
Code:
on *:text:!commands:#: {
  if ($file(commands.txt)) { .play # commands.txt 2000 }
}

.play # commands.txt 2000
play msgs the file contents one line at a time.
The 2000 refers to milliseconds delay between each line (2000 ms = 2 seconds), you can change that as you wish.

For more options, see "/help /play" (especially the second option that pops up when typing that).
oh that helps a lot thanks! is there a way where you can only say the first word on that line then go to the next. for it won't Spam it the whole Commands. instead it would just say !example !Commands !ect
© mIRC Discussion Forums