You did it right you just filled it out in a slightly confusing way. Use:
on *:TEXT:*:#: { if ($1 == !givecookie) { ...commands } if ($1 == !givecake) { ...commands } .... }
That way would work too, yes?