    # File lib/rbot/irc.rb, line 1795
        def new_channel(name, topic=nil, users=[], fails=true)
          if name.nil_or_empty?
            raise "Tried to look for empty or nil channel name #{name.inspect}" if fails
            return nil
          end
          ex = get_chan(name)
          if ex
            raise "Channel #{name} already exists on server #{self}" if fails
            return ex
          else

            prefix = name[0].chr

            # Give a warning if the new Channel goes over some server limits.
            #
            # FIXME might need to raise an exception
            #
            warn "#{self} doesn't support channel prefix #{prefix}" unless @supports[:chantypes].include?(prefix)
            warn "#{self} doesn't support channel names this long (#{name.length} > #{@supports[:channellen]})" unless name.length <= @supports[:channellen]

            # Next, we check if we hit the limit for channels of type +prefix+
            # if the server supports +chanlimit+
            #
            @supports[:chanlimit].keys.each { |k|
              next unless k.include?(prefix)
              count = 0
              channel_names.each { |n|
                count += 1 if k.include?(n[0])
              }
              # raise IndexError, "Already joined #{count} channels with prefix #{k}" if count == @supports[:chanlimit][k]
              warn "Already joined #{count}/#{@supports[:chanlimit][k]} channels with prefix #{k}, we may be going over server limits" if count >= @supports[:chanlimit][k]
            }

            # So far, everything is fine. Now create the actual Channel
            #
            chan = Channel.new(name, topic, users, :server => self)

            # We wade through +prefix+ and +chanmodes+ to create appropriate
            # lists and flags for this channel

            @supports[:prefix][:modes].each { |mode|
              chan.create_mode(mode, Channel::UserMode)
            } if @supports[:prefix][:modes]

            @supports[:chanmodes].each { |k, val|
              if val
                case k
                when :typea
                  val.each { |mode|
                    chan.create_mode(mode, Channel::ModeTypeA)
                  }
                when :typeb
                  val.each { |mode|
                    chan.create_mode(mode, Channel::ModeTypeB)
                  }
                when :typec
                  val.each { |mode|
                    chan.create_mode(mode, Channel::ModeTypeC)
                  }
                when :typed
                  val.each { |mode|
                    chan.create_mode(mode, Channel::ModeTypeD)
                  }
                end
              end
            }

            @channels << chan
            # debug "Created channel #{chan.inspect}"
            return chan
          end
        end