text: const Maze     = require('./Maze');
  const MazeGame = require('./MazeGame');
  const {Math}         = require('../../../Utils');
  const {processImage} = require('../image-utils');
  
  module.exports = {
  	'maze': {
  		aliases: ['labyrinth'],
  		category: 'Fun',
  		title: 'Maze',
  		info: 'Play the maze runner game. You can set the maze size (limited from 10x10 up to 100x100).',
  		parameters: ['[width]', '[height]'],
  		permissions: 'inclusive',
  		fn({client, context, args}) {
  			let width, height;
  			if (args.length == 1) {
  				[width, height] = String(args[0]).split('x');
  			} else {
  				[width, height] = args;
  			}
  			let options = {};
  			options.width  = Math.minmax(Number(width)||0, 20, 100);
  			options.height = Math.minmax(Number(width)||0, 20, 100);
  			let maze = new MazeGame(context, options);
  			maze.startGame(client);
  		},
  		subcommands: {
  			'generate': {
  				aliases: ['gen','make','create'],
  				category: 'Image',
  				title: 'Maze Generator',
  				info: 'Generate a maze.',
  				parameters: ['[width]', '[height]'],
  				flags: ['scale'],
  				fn({client, args, flags}) {
  					let width, height, scale = Number(flags.get('scale')) || 1;
  					if (args.length == 1) {
  						[width, height] = String(args[0]).split('x');
  					} else {
  						[width, height] = args;
  					}
  					width = Math.minmax(Number(width), 30, 1000);
  					height = Math.minmax(Number(width), 30, 1000);
  					scale = Math.minmax(scale, 1, 10);
  					return Maze.generate(width, height, scale).getBufferAs('maze.png');
  				}
  			},
  			'solve': {
  				category: 'Image',
  				title: 'Maze Solver',
  				info: 'Solve a maze generated by this bot. Might or might not work with other mazes.',
  				parameters: ['[imageURL]'],
  				flags: ['scale'],
  				fn({client, args, flags, channelID}) {
  					let scale = Number(flags.get('scale')) || 1;
  					return processImage(client, args, channelID, image => Maze.solve(image,scale), 'maze-solution.png');
  				}
  			}
  		}
  	}
  };
  