public async Task AddZoneType(params string[] args) { if (args.Count() <= 0) { await BotUtils.ReplyAsync_Error(Context, "You must specify a name for the zone type."); } else if (args.Count() > 4) { await BotUtils.ReplyAsync_Error(Context, "Too many arguments have been provided."); } else { string name = args[0]; string icon = ZoneType.DefaultIcon; System.Drawing.Color color = ZoneType.DefaultColor; string description = ""; if (await ZoneUtils.GetZoneTypeAsync(name) != null) { // If a zone type with this name already exists, do not create a new one. await BotUtils.ReplyAsync_Warning(Context, string.Format("A zone type named \"{0}\" already exists.", name)); } else { // Read the rest of the arguments. for (int i = 1; i < args.Count(); ++i) { if (Bot.DiscordUtils.IsEmoji(args[i])) { icon = args[i]; } else if (StringUtils.TryParseColor(args[i], out System.Drawing.Color result)) { color = result; } else if (string.IsNullOrEmpty(description)) { description = args[i]; } else { await BotUtils.ReplyAsync_Warning(Context, string.Format("Invalid argument provided: {0}", args[i])); } } ZoneType type = new ZoneType { Name = name, Icon = icon, Description = description, Color = color }; // Add the zone type to the database. await ZoneUtils.AddZoneTypeAsync(type); await BotUtils.ReplyAsync_Success(Context, string.Format("Successfully created new zone type **{0}**.", type.Name)); } } }