public async Task AddZone(string name, string type = "", string description = "") { if (string.IsNullOrEmpty(name)) { await BotUtils.ReplyAsync_Error(Context, "Zone name cannot be empty."); } else { // Allow the user to specify zones with numbers (e.g., "1") or single letters (e.g., "A"). // Otherwise, the name is taken as-is. name = ZoneUtils.FormatZoneName(name).ToLower(); // If an invalid type was provided, assume the user meant it as a description instead. // i.e., "addzone <name> <description>" ZoneType zone_type = await ZoneUtils.GetZoneTypeAsync(type); if (zone_type is null || zone_type.Id == ZoneType.NullZoneTypeId) { description = type; // Attempt to determine the zone type automatically if one wasn't provided. // Currently, this is only possible if users are using the default zone types (i.e. "aquatic" and "terrestrial"). zone_type = await ZoneUtils.GetDefaultZoneTypeAsync(name); } if (await ZoneUtils.GetZoneAsync(name) != null) { // Don't attempt to create the zone if it already exists. await BotUtils.ReplyAsync_Warning(Context, string.Format("A zone named \"{0}\" already exists.", ZoneUtils.FormatZoneName(name))); } else { await ZoneUtils.AddZoneAsync(new Zone { Name = name, Description = description, ZoneTypeId = zone_type.Id }); await BotUtils.ReplyAsync_Success(Context, string.Format("Successfully created new {0} zone, **{1}**.", zone_type.Name.ToLower(), ZoneUtils.FormatZoneName(name))); } } }