Alright I'm gonna play with this a bit.
Thanks RusselB.

One question though, could you please help with it as well?
How would I create a variable that contains the name of $2.

Like: set (%failedchan- $+ $2) $2
Imagine failed channel name is #test

So, that it would create a variable with the name:
%failedchan-#test
with value: #test

Does anyone know? I need this very often, so I would like to learn it.
Thanks in advance