is not the best way to grab the bans. i've found that if the banlist has not been modified for a bit such as adding/removing of bans. that some or all of the bans will not show up this is an example of another way to do it that i set up via my bot.
look at his whole code. he checks $chan().ibl before initiating the dialog and will request the ban list from the server if the IBL isn't necessarily up-to-date. that is the most sensible method.