There is alreay an auto join command.

To add a channel to your auto command try:

Code:
/msg NickServ AJOIN ADD #channel


To add a channel that uses a key try:

Code:
/msg NickServ AJOIN ADD #channel key


To add all the channels you currently are try:

Code:
/msg NickServ AJOIN ADDALL


To see the complete list on your autojoin try:

Code:
/msg NickServ AJOIN LIST


To remove a channel try:

Code:
/msg NickServ AJOIN DEL #channel


To delete all your channels on autojoin try:

Code:
/msg NickServ AJOIN CLEAR